ALTER FOREIGN TABLE (for HDFS or OBS)

Function

Modifies an HDFS or OBS foreign table.

Precautions

None

Syntax

Parameter Description

For details on how to modify other parameters in the foreign table, such as IF EXISTS, see Parameter Description in ALTER TABLE.

Examples

  1. Establish HDFS_Server, with HDFS_FDW or DFS_FDW as the foreign data wrapper.
    1
    CREATE SERVER hdfs_server FOREIGN DATA WRAPPER HDFS_FDW OPTIONS (address '10.10.0.100:25000,10.10.0.101:25000',hdfscfgpath '/opt/hadoop_client/HDFS/hadoop/etc/hadoop',type'HDFS');
    
  2. Create an HDFS foreign table without partition keys.
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    DROP FOREIGN TABLE IF EXISTS ft_region;
    CREATE FOREIGN TABLE ft_region
    (
        R_REGIONKEY INT4,
        R_NAME TEXT,
        R_COMMENT TEXT
    )
    SERVER
        hdfs_server
    OPTIONS
    (
        FORMAT 'orc',
        encoding 'utf8',
        FOLDERNAME '/user/hive/warehouse/gauss.db/region_orc11_64stripe/'
    )
    DISTRIBUTE BY 
         roundrobin;
    
  3. Change the type of the r_name column to text in the ft_region foreign table.
    1
    ALTER FOREIGN TABLE ft_region ALTER r_name TYPE TEXT;
    
  4. Run the following command to mark the r_name column of the ft_region foreign table as not null:
    1
    ALTER FOREIGN TABLE ft_region ALTER r_name SET NOT NULL;
    

Helpful Links

CREATE FOREIGN TABLE (SQL on OBS or Hadoop), DROP FOREIGN TABLE