Iceberg on Flink DDL Syntax
Basic Table Creation Statement
The most basic table creation statement specifies the table name, column definitions, and table properties.
CREATE TABLE lf_iceberg_catalog.iceberg_db.iceberg_table (
id BIGINT COMMENT 'unique id',
data STRING NOT NULL
) WITH ('format-version'='2'); The following common clauses are supported:
- PARTITION BY (column1, column2, ...): Configures partitioning. Note that Flink does not support hidden partitioning.
- COMMENT 'table document': Sets the table description.
- WITH ('key'='value', ...): Sets table configurations (stored in Iceberg table properties).
PRIMARY KEY (Primary Key Constraint)
You can declare a primary key constraint for one or more columns. The primary key must be unique and cannot contain NULL values. The primary key constraint is required for the UPSERT mode.
Table creation statement with a primary key constraint
CREATE TABLE lf_iceberg_catalog.iceberg_db.iceberg_table (
id BIGINT COMMENT 'unique id',
data STRING NOT NULL,
PRIMARY KEY(id) NOT ENFORCED
) WITH ('format-version'='2'); PARTITIONED BY (Partitioned tables)
Use the PARTITIONED BY clause to create a partitioned table.
Partitioned table creation statement
CREATE TABLE lf_iceberg_catalog.iceberg_db.iceberg_table (
id BIGINT COMMENT 'unique id',
data STRING NOT NULL
) PARTITIONED BY (data)
WITH ('format-version'='2'); CREATE TABLE LIKE (Replicating the Table Structure)
Create a new table with the same structure, partitions, and table properties as an existing table.
CREATE TABLE lf_iceberg_catalog.iceberg_db.iceberg_table ( id BIGINT COMMENT 'unique id', data STRING ); CREATE TABLE lf_iceberg_catalog.iceberg_db.iceberg_table_like LIKE lf_iceberg_catalog.iceberg_db.iceberg_table;
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot