CREATE CATALOG
Hive Catalog
This creates an Iceberg catalog namedhive_catalog that loads tables from Hive metastore:
Hadoop Catalog
Iceberg supports a directory-based catalog in HDFS:
Execute the SQL command
USE CATALOG hadoop_catalog to set the current catalog.
REST Catalog
This creates an Iceberg catalog that loads tables from a REST catalog:Custom Catalog
Flink supports loading a custom IcebergCatalog implementation by specifying the catalog-impl property:
Create via YAML Config
Catalogs can be registered insql-client-defaults.yaml before starting the SQL client:
Create via SQL Files
The Flink SQL Client supports the-i startup option to execute an initialization SQL file:
-i <init.sql> option to initialize SQL Client session:
CREATE DATABASE
By default, Iceberg will use thedefault database in Flink. Create a separate database to avoid creating tables under the default database:
CREATE TABLE
Basic Table
PARTITION BY (column1, column2, ...)to configure partitioning (Flink does not yet support hidden partitioning)COMMENT 'table document'to set a table descriptionWITH ('key'='value', ...)to set table configuration which will be stored in Iceberg table properties
Specify Table Location
To specify the table location, useWITH ('location'='fully-qualified-uri'):
PRIMARY KEY
Primary key constraint can be declared for a column or a set of columns, which must be unique and do not contain null. It’s required for UPSERT mode.PARTITIONED BY
To create a partition table, usePARTITIONED BY:
Iceberg supports hidden partitioning but Flink doesn’t support partitioning by a function on columns. There is no way to support hidden partitions in the Flink DDL.
CREATE TABLE LIKE
To create a table with the same schema, partitioning, and table properties as another table, useCREATE TABLE LIKE:
ALTER TABLE
Alter Table Properties
Iceberg only supports altering table properties:Rename Table
DROP TABLE
To delete a table, run:Examples
Complete Table Creation Flow
Alter Table Example
Next Steps
Queries
Learn how to query Iceberg tables
Writes
Write data to Iceberg tables