Creates an EXTERNAL schema. This syntax is supported only in 8.3.0 and later versions.
The external schema is used to access tables of the LakeFormation, DLI, or HMS service. You can use an external schema name as the prefix for access. If there is no schema name prefix, you can access the named objects in the current schema.
1 2 3 4 5 6 7 8 | CREATE EXTERNAL SCHEMA schema_name WITH SOURCE source_name DATABASE 'database_name' SERVER server_name [ CATALOG 'catalog_name' ] [ OPTIONS ( { option_name ' value ' } [, ...] ) ] [METAADDRESS 'address'] [CONFIGURATION 'confpath']; |
Name of an external schema.
Value range: a string. It must comply with the naming convention.
Type of the external metadata storage engine. Currently, source_type can only be dli, lakeformation, or hive.
Database corresponding to the external schema.
Value range: an existing foreign server whose type is lf, dli, obs, or hdfs.
You can associate an external schema with a foreign server to access external data.
Catalog to be accessed in LakeFormation. This parameter is mandatory only when server type is set to lf.
Specifies the following parameters for a foreign table: This function is supported only by 8.3.0 and later versions.
dli_project_id
Specifies the project ID corresponding to DLI. You can obtain the project ID from the management console. This parameter is available only when the server type is DLI.
Hivemetastore communication interface. This parameter is supported only by 9.1.0 and later versions.
If objects in the schema on the current search path are with the same name, specify the schemas different objects are in. You can run the SHOW SEARCH_PATH command to check the schemas on the current search path.
For details about how to create lf_server, see section "Managing LakeFormation Data Sources" in User Guide.
1 2 3 4 5 | CREATE EXTERNAL SCHEMA ex_lf WITH SOURCE lakeformation DATABASE 'demo' SERVER lf_server CATALOG 'hive'; |
1 2 3 4 5 | SELECT COUNT(*) FROM ex_dli.test_lf; count ------- 20 (1 row) |
DLI tables and DLI internal tables in Lakehouse mode can be accessed.
1 2 3 4 5 6 7 8 9 | CREATE SERVER dli_server FOREIGN DATA WRAPPER DFS_FDW OPTIONS ( ADDRESS 'obs.example.com', ACCESS_KEY 'xxxxxxxxx', SECRET_ACCESS_KEY 'yyyyyyyyyyyyy', TYPE 'DLI', DLI_ADDRESS 'dli.example.com', DLI_ACCESS_KEY 'xxxxxxxxx', DLI_SECRET_ACCESS_KEY 'yyyyyyyyyyyyy' ); |
1 2 3 4 5 | CREATE EXTERNAL SCHEMA ex_dli WITH SOURCE dli DATABASE 'database123' SERVER dli_server options (dli_project_id 'xxxxxxxxxxxxxxx'); |
1 2 3 4 5 | SELECT COUNT(*) FROM ex_dli.test_dli; count ------- 20 (1 row) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | CREATE SERVER hdfs_server FOREIGN DATA WRAPPER HDFS_FDW OPTIONS ( address '***.***.***.***:9000', type'HDFS'); CREATE SERVER obs_server FOREIGN DATA WRAPPER dfs_fdw OPTIONS ( address 'obs.example.com' , ACCESS_KEY 'access_key_value_to_be_replaced', SECRET_ACCESS_KEY 'secret_access_key_value_to_be_replaced', encrypt 'on', type 'obs' ); |
1 2 3 4 5 6 | CREATE EXTERNAL SCHEMA ex_hms WITH SOURCE source_type DATABASE 'db_name' SERVER srv_name METAADDRESS 'address' CONFIGURATION 'confpath'; |
1 2 3 4 5 | SELECT COUNT(*) FROM ex_hms.test_hms; count ------- 20 (1 row) |