跳到主要内容
版本: 最新版本-3.5

CREATE EXTERNAL CATALOG

CREATE EXTERNAL CATALOG 语句用于创建外部 Catalog。您可以创建外部 Catalog 来查询外部数据源中的数据,而无需将数据加载到 StarRocks 中或创建外部表。目前,您可以创建以下类型的外部 Catalog:

  • Hive catalog:用于查询 Apache Hive™ 中的数据。
  • Iceberg catalog:用于查询 Apache Iceberg 中的数据。
  • Hudi catalog:用于查询 Apache Hudi 中的数据。
  • Delta Lake catalog:用于查询 Delta Lake 中的数据。
  • JDBC catalog:用于查询 JDBC 兼容的数据源。
  • Elasticsearch catalog:用于查询 Elasticsearch 中的数据。从 v3.1 版本开始支持 Elasticsearch catalog。
  • Paimon catalog:用于查询 Apache Paimon 中的数据。从 v3.1 版本开始支持 Paimon catalog。
  • Unified catalog:用于将来自 Hive、Iceberg、Hudi 和 Delta Lake 数据源的数据作为统一数据源进行查询。从 v3.2 版本开始支持 Unified catalog。

注意

  • 从 v3.0 及更高版本开始,此语句需要 SYSTEM 级别的 CREATE EXTERNAL CATALOG 权限。
  • 在创建外部 Catalog 之前,请配置 StarRocks 集群以满足外部数据源的数据存储系统(如 Amazon S3)、元数据服务(如 Hive Metastore)和身份验证服务(如 Kerberos)的要求。有关更多信息,请参阅每个外部 Catalog 主题中的“开始之前”部分。

语法

CREATE EXTERNAL CATALOG [IF NOT EXISTS] <catalog_name>
[COMMENT <comment>]
PROPERTIES ("key"="value", ...)

参数

参数必需描述
catalog_name外部 Catalog 的名称。有关命名约定,请参见系统限制
comment外部 Catalog 的描述。
PROPERTIES外部 Catalog 的属性。根据外部 Catalog 的类型配置属性。有关更多信息,请参见Hive catalogIceberg catalogHudi catalogDelta Lake catalogJDBC Catalog

示例

示例 1:创建一个名为 hive_metastore_catalog 的 Hive Catalog。对应的 Hive 集群使用 Hive Metastore 作为其元数据服务。

CREATE EXTERNAL CATALOG hive_metastore_catalog
COMMENT "External catalog to Hive"
PROPERTIES(
"type"="hive",
"hive.metastore.uris"="thrift://xx.xx.xx.xx:9083"
);

示例 2:创建一个名为 hive_glue_catalog 的 Hive Catalog。对应的 Hive 集群使用 AWS Glue 作为其元数据服务。

CREATE EXTERNAL CATALOG hive_glue_catalog
COMMENT "External catalog to Hive"
PROPERTIES(
"type"="hive",
"hive.metastore.type"="glue",
"aws.hive.metastore.glue.aws-access-key"="xxxxxx",
"aws.hive.metastore.glue.aws-secret-key"="xxxxxxxxxxxx",
"aws.hive.metastore.glue.endpoint"="https://glue.x-x-x.amazonaws.com"
);

示例 3:创建一个名为 iceberg_metastore_catalog 的 Iceberg Catalog。对应的 Iceberg 集群使用 Hive Metastore 作为其元数据服务。

CREATE EXTERNAL CATALOG iceberg_metastore_catalog
COMMENT "External catalog to Iceberg"
PROPERTIES(
"type"="iceberg",
"iceberg.catalog.type"="hive",
"iceberg.catalog.hive.metastore.uris"="thrift://xx.xx.xx.xx:9083"
);

示例 4:创建一个名为 iceberg_glue_catalog 的 Iceberg Catalog。对应的 Iceberg 集群使用 AWS Glue 作为其元数据服务。

CREATE EXTERNAL CATALOG iceberg_glue_catalog
COMMENT "External catalog to Iceberg"
PROPERTIES(
"type"="iceberg",
"iceberg.catalog.type"="glue",
"aws.hive.metastore.glue.aws-access-key"="xxxxx",
"aws.hive.metastore.glue.aws-secret-key"="xxxxxxxxxxxx",
"aws.hive.metastore.glue.endpoint"="https://glue.x-x-x.amazonaws.com"
);

示例 5:创建一个名为 hudi_metastore_catalog 的 Hudi Catalog。对应的 Hudi 集群使用 Hive Metastore 作为其元数据服务。

CREATE EXTERNAL CATALOG hudi_metastore_catalog
COMMENT "External catalog to Hudi"
PROPERTIES(
"type"="hudi",
"hive.metastore.uris"="thrift://xx.xx.xx.xx:9083"
);

示例 6:创建一个名为 hudi_glue_catalog 的 Hudi Catalog。对应的 Hudi 集群使用 AWS Glue 作为其元数据服务。

CREATE EXTERNAL CATALOG hudi_glue_catalog
COMMENT "External catalog to Hudi"
PROPERTIES(
"type"="hudi",
"hive.metastore.type"="glue",
"aws.hive.metastore.glue.aws-access-key"="xxxxxx",
"aws.hive.metastore.glue.aws-secret-key"="xxxxxxxxxxxx",
"aws.hive.metastore.glue.endpoint"="https://glue.x-x-x.amazonaws.com"
);

示例 7:创建一个名为 delta_metastore_catalog 的 Delta Lake Catalog。对应的 Delta Lake 服务使用 Hive Metastore 作为其元数据服务。

CREATE EXTERNAL CATALOG delta_metastore_catalog
COMMENT "External catalog to Delta"
PROPERTIES(
"type"="deltalake",
"hive.metastore.uris"="thrift://xx.xx.xx.xx:9083"
);

示例 8:创建一个名为 delta_glue_catalog 的 Delta Lake Catalog。对应的 Delta Lake 服务使用 AWS Glue 作为其元数据服务。

CREATE EXTERNAL CATALOG delta_glue_catalog
COMMENT "External catalog to Delta"
PROPERTIES(
"type"="deltalake",
"hive.metastore.type"="glue",
"aws.hive.metastore.glue.aws-access-key"="xxxxxx",
"aws.hive.metastore.glue.aws-secret-key"="xxxxxxxxxxxx",
"aws.hive.metastore.glue.endpoint"="https://glue.x-x-x.amazonaws.com"
);

参考

  • 要查看 StarRocks 集群中的所有 Catalog,请参见SHOW CATALOGS
  • 要查看外部 Catalog 的创建语句,请参见SHOW CREATE CATALOG
  • 要从 StarRocks 集群中删除外部 Catalog,请参见DROP CATALOG