跳到主要内容

Iceberg JDBC Catalog

本文档用于介绍通过 CREATE CATALOG 语句连接并访问使用 JDBC 接口的 Iceberg Catalog 元数据服务时所支持的参数。

提示

该功能为试验功能,自 4.1.0 版本支持。

参数总览

属性名称描述默认值是否必须
iceberg.jdbc.uri指定 JDBC 连接地址-
iceberg.jdbc.userJDBC 连接用户名-
iceberg.jdbc.passwordJDBC 连接密码-
warehouse指定 iceberg warehouse-
iceberg.jdbc.init-catalog-tables是否在首次使用时自动初始化 Catalog 相关的表结构true
iceberg.jdbc.schema-versionJDBC Catalog 使用的 Schema 版本,支持 V0V1V0
iceberg.jdbc.strict-mode是否启用严格模式,严格模式下会对元数据进行更严格的校验false
iceberg.jdbc.driver_classJDBC 驱动类名,如 org.postgresql.Drivercom.mysql.cj.jdbc.Driver-
iceberg.jdbc.driver_urlJDBC 驱动 JAR 包的路径-

注:

  1. Iceberg JDBC Catalog 支持多种关系型数据库作为后端存储,包括 PostgreSQL、MySQL、SQLite 等。

  2. 需要确保 JDBC 驱动 JAR 包可访问。可以通过 iceberg.jdbc.driver_url 指定驱动位置。

示例配置

PostgreSQL 作为元数据存储

使用 PostgreSQL 数据库存储 Iceberg 元数据:

CREATE CATALOG iceberg_jdbc_postgresql PROPERTIES (
'type' = 'iceberg',
'iceberg.catalog.type' = 'jdbc',
'iceberg.jdbc.uri' = 'jdbc:postgresql://127.0.0.1:5432/iceberg_db',
'iceberg.jdbc.user' = 'iceberg_user',
'iceberg.jdbc.password' = 'password',
'iceberg.jdbc.init-catalog-tables' = 'true',
'iceberg.jdbc.schema-version' = 'V1',
'iceberg.jdbc.driver_class' = 'org.postgresql.Driver',
'iceberg.jdbc.driver_url' = '<jdbc_driver_jar>',
'warehouse' = 's3://bucket/warehouse',
's3.access_key' = '<ak>',
's3.secret_key' = '<sk>',
's3.endpoint' = 'https://s3.us-east-1.amazonaws.com',
's3.region' = 'us-east-1'
);

MySQL 作为元数据存储

使用 MySQL 数据库存储 Iceberg 元数据:

CREATE CATALOG iceberg_jdbc_mysql PROPERTIES (
'type' = 'iceberg',
'iceberg.catalog.type' = 'jdbc',
'iceberg.jdbc.uri' = 'jdbc:mysql://127.0.0.1:3306/iceberg_db',
'iceberg.jdbc.user' = 'iceberg_user',
'iceberg.jdbc.password' = 'password',
'iceberg.jdbc.init-catalog-tables' = 'true',
'iceberg.jdbc.schema-version' = 'V1',
'iceberg.jdbc.driver_class' = 'com.mysql.cj.jdbc.Driver',
'iceberg.jdbc.driver_url' = '<jdbc_driver_jar>'
'warehouse' = 's3://bucket/warehouse',
's3.access_key' = '<ak>',
's3.secret_key' = '<sk>',
's3.endpoint' = 'https://s3.us-east-1.amazonaws.com',
's3.region' = 'us-east-1'
);

SQLite 作为元数据存储

使用 SQLite 数据库存储 Iceberg 元数据(适用于测试环境):

CREATE CATALOG iceberg_jdbc_sqlite PROPERTIES (
'type' = 'iceberg',
'iceberg.catalog.type' = 'jdbc',
'iceberg.jdbc.uri' = 'jdbc:sqlite:/tmp/iceberg_catalog.db',
'iceberg.jdbc.init-catalog-tables' = 'true',
'iceberg.jdbc.schema-version' = 'V1',
'iceberg.jdbc.driver_class' = 'org.sqlite.JDBC',
'iceberg.jdbc.driver_url' = '<jdbc_driver_jar>'
'warehouse' = 's3://bucket/warehouse',
's3.access_key' = '<ak>',
's3.secret_key' = '<sk>',
's3.endpoint' = 'https://s3.us-east-1.amazonaws.com',
's3.region' = 'us-east-1'
);