Updated on 2026-11-06 GMT+08:00

Querying and Writing to Iceberg

Important Notes

  • Checkpointing is required for streaming writes to Iceberg.
  • Streaming reads are not supported for Iceberg tables that use UPSERT writes.

Code Examples

Example 1: Append data without a primary key to an Iceberg table.

CREATE CATALOG lf_iceberg_catalog
WITH
  (
    'type' = 'iceberg',
    'catalog-type' = 'lakeformation'
  );
CREATE TABLE IF NOT EXISTS lf_iceberg_catalog.iceberg_db.iceberg_table (
  id BIGINT, 
  data STRING
)WITH('format-version' = '2');

CREATE TABLE kafka_source (id BIGINT, data STRING)
WITH
  (
    'connector' = 'kafka',
    'topic' = 'user-events',
    'properties.bootstrap.servers' = '127.0.0.1:9092',
    'properties.group.id' = 'flink-consumer-group',
    'scan.startup.mode' = 'latest-offset',
    'format' = 'json'
  );

INSERT INTO
  lf_iceberg_catalog.iceberg_db.iceberg_table
SELECT
  *
FROM
  kafka_source

Example 2: Read an Iceberg table in streaming mode.

CREATE CATALOG lf_iceberg_catalog
WITH
  (
    'type' = 'iceberg',
    'catalog-type' = 'lakeformation'
  );

CREATE TABLE sink (id BIGINT, data STRING)
WITH
  ('connector' = 'print');

INSERT INTO
  sink
SELECT
  *
FROM
  lf_iceberg_catalog.iceberg_db.iceberg_table /*+ OPTIONS('streaming'='true', 'monitor-interval'='60s') */;