CREATE EXTERNAL CATALOG hive_catalog PROPERTIES ( "hive.metastore.uris"="thrift://{hms_ip:hms_port}", "type" = "hive");
select * from hive_catalog.db_1.table1 limit 1;
CREATE EXTERNAL CATALOG hive_tos_catalog PROPERTIES ( "type"="hive", "hive.metastore.uris" = "thrift://{hms_ip:hms_port}", "aws.s3.access_key"="xxx", "aws.s3.secret_key"="xxx==", "aws.s3.endpoint"="{endpoint,必须是s3格式的endpoint,例如: tos-s3-cn-beijing.ivolces.com}", "aws.s3.enable_ssl" = "false" );
select * from hive_tos_catalog.hive.hive_tos;
CREATE EXTERNAL CATALOG hudi_catalog PROPERTIES ( "type"="hudi", "hive.metastore.uris"="thrift://{hms_ip:hms_port}", );
select * from hudi_catalog.db_1.table1 limit 1;
CREATE EXTERNAL CATALOG hudi_tos_catalog PROPERTIES ( 'type'='hudi', 'hive.metastore.uris' = 'thrift://{hms_ip:hms_port}', "aws.s3.access_key"="xx", "aws.s3.secret_key"="xxx==", "aws.s3.endpoint"="{endpoint,必须是s3格式的endpoint,例如: tos-s3-cn-beijing.ivolces.com}", "aws.s3.enable_ssl" = "false" );
select * from hudi_tos_catalog.db_1.table1 limit 1;
CREATE EXTERNAL CATALOG iceberg_catalog PROPERTIES ( 'type'='iceberg', 'iceberg.catalog.type' = 'hive', 'iceberg.catalog.hive.metastore.uris' = 'thrift://{hms_ip:hms_port}' );
select * from iceberg_catalog.iceberg.iceberg_hdfs;
CREATE EXTERNAL CATALOG iceberg_tos_catalog PROPERTIES ( 'type'='iceberg', 'iceberg.catalog.type' = 'hive', 'hive.metastore.uris' = 'thrift://{hms_ip:hms_port}', "aws.s3.access_key"="xxx", "aws.s3.secret_key"="xxxx==", "aws.s3.endpoint"="{endpoint,必须是s3格式的endpoint,例如: tos-s3-cn-beijing.ivolces.com}", "aws.s3.enable_ssl" = "false" );
select * from iceberg_tos_catalog.iceberg.iceberg_tos;
CREATE EXTERNAL CATALOG paimon_catalog_hdfs PROPERTIES ( "type" = "paimon", "paimon.catalog.type" = "hive", "paimon.catalog.warehouse" = "{hdfs paimon root path}", "hive.metastore.uris" = "thrift://{hms_ip:hms_port}", );
set catalog paimon_catalog_hdfs; show databases; use test_db_hdfs; show tables; select * from paimon_catalog_hdfs.test_db_hdfs.test_tbl_hdfs;
CREATE EXTERNAL CATALOG paimon_catalog_fs PROPERTIES ( "type" = "paimon", "paimon.catalog.type" = "filesystem", "paimon.catalog.warehouse" = "{hdfs paimon root path, 必须是s3协议,例如:s3://sr-qa/xxx}" , "aws.s3.enable_ssl" = "false", "aws.s3.endpoint"="{endpoint,必须是s3格式的endpoint,例如: tos-s3-cn-beijing.ivolces.com}", "aws.s3.access_key" = "xxx", "aws.s3.secret_key" = "xxx==" );
set catalog paimon_catalog_fs; show databases; use test_db_fs; show tables; select * from paimon_catalog_fs.test_db_fs.test_tbl_fs;
CREATE EXTERNAL CATALOG <catalog_name [COMMENT <comment] PROPERTIES ("key"="value", ...)
其中参数释义:
catalog_name
JDBC Catalog 的名称。命名要求如下:
必须由字母 (a-z 或 A-Z)、数字 (0-9) 或下划线 (_) 组成,且只能以字母开头。
总长度不能超过 1023 个字符。
Catalog 名称大小写敏感。
comment
JDBC Catalog 的描述。此参数为可选。
PROPERTIES
JDBC Catalog 的属性,包含如下必填配置项:
参数 | 说明 |
---|---|
type | 资源类型,固定取值为 jdbc。 |
user | 目标数据库登录用户名。 |
password | 目标数据库用户登录密码。 |
jdbc_uri | JDBC 驱动程序连接目标数据库的 URI。如果使用 MySQL,格式为:"jdbc:mysql://ip:port"。如果使用 PostgreSQL,格式为 "jdbc:postgresql://ip:port/db_name"。 |
driver_url | 用于下载 JDBC 驱动程序 JAR 包的 URL。支持使用 HTTP 协议或者 file 协议,例如https://repo1.maven.org/maven2/org/postgresql/postgresql/42.3.3/postgresql-42.3.3.jar 和 file:///home/disk1/postgresql-42.3.3.jar。 说明 您也可以把 JDBC 驱动程序部署在 FE 或 BE(或 CN)所在节点上任意相同路径下,然后把 driver_url 设置为该路径,格式为 file:/// |
driver_class | JDBC 驱动程序的类名称。以下是常见数据库引擎支持的 JDBC 驱动程序类名称:MySQL:com.mysql.jdbc.Driver(MySQL 5.x 及之前版本)、com.mysql.cj.jdbc.Driver(MySQL 6.x 及之后版本)PostgreSQL: org.postgresql.Driver |
CREATE EXTERNAL CATALOG jdbc_mysql PROPERTIES ( "type"="jdbc", "user"="root", "password"="changeme", "jdbc_uri"="jdbc:mysql://127.0.0.1:3306", "driver_url"="https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.28/mysql-connector-java-8.0.28.jar", "driver_class"="com.mysql.cj.jdbc.Driver" );
# 查看所有catalog SHOW CATALOGS; # 查看某个catalog SHOW CREATE CATALOG jdbc_mysql;
查看catalog的数据
SHOW DATABASES FROM jdbc_mysql;
SET CATALOG jdbc_mysql;
USE db_name;
USE jdbc_mysql.db_name;
SELECT * FROM table_name;
CREATE EXTERNAL CATALOG jdbc_pg PROPERTIES ( "type"="jdbc", "user"="postgres", "password"="changeme", "jdbc_uri"="jdbc:postgresql://127.0.0.1:5432/jdbc_test", "driver_url"="https://repo1.maven.org/maven2/org/postgresql/postgresql/42.3.3/postgresql-42.3.3.jar", "driver_class"="org.postgresql.Driver" );
# 查看所有catalog SHOW CATALOGS; # 查看某个catalog SHOW CREATE CATALOG jdbc_pg;
查看catalog的数据
SHOW DATABASES FROM jdbc_pg;
SET CATALOG jdbc_pg;
USE db_name;
USE jdbc_pg.db_name;
SELECT * FROM table_name;