Creating Iceberg tables

Create an Iceberg table to store the results of a streaming job in an open table format, or to read an Iceberg table. You can use the tables of an Iceberg catalog or define a table with DDL.

An Iceberg catalog with the Hive backing catalog type needs the Cloudera Base Connector, which provides the Hive Metastore configuration. To keep your Iceberg data in the storage that Anywhere Cloud provides, use a Cloudera Harmony Catalog, because Anywhere Cloud does not manage Iceberg tables through a Hive Metastore.

Support

Cloudera SQL Stream Builder (SSB) works with Iceberg tables through Flink SQL. The following table shows which Iceberg features you can use from SSB:

Table 1. Iceberg feature support
Feature Support Notes
CREATE TABLE Supported Partition columns can only be identity columns. CREATE CATALOG, CREATE DATABASE, and DROP TABLE are also supported.
Schema evolution Supported Column changes only. ALTER TABLE can add, drop, rename, reorder, and comment columns, change their type and nullability, and set the primary key.
Partition evolution Not supported None
Drop partition Not supported None
SELECT Supported Works in batch and streaming jobs. Streaming reads return appended rows only.
Metadata tables Supported For example, my_table$snapshots
Partition pruning Supported None
Time travel Supported In batch jobs, read a snapshot with the snapshot-id or as-of-timestamp read option. To run a batch job, set Execution Mode to APPLICATION and Runtime Mode to BATCH.
Branching Supported Read a branch with the branch read option.
Tagging Supported Read a tag with the tag read option, or the changes between two tags with start-tag and end-tag.
Rollback Supported Through ALTER TABLE only. To roll back to a snapshot, use ALTER TABLE table SET ('current-snapshot-id' = 'snapshot-id'). The cherry-pick-snapshot-id property is also supported.
INSERT Supported INSERT INTO works in batch and streaming jobs. INSERT OVERWRITE works in batch jobs only. To run a batch job, set Execution Mode to APPLICATION and Runtime Mode to BATCH. For more information, see Running a job in application mode.
Update and delete Supported Upsert only. Rows are updated and deleted through upsert or changelog input, not with UPDATE or DELETE statements. For upsert, see the equality deletes row.
MERGE Not supported None
Equality deletes Supported Upsert writes equality deletes. To turn on upsert, set the write.upsert.enabled table property to true on a table that has a primary key.
Positional deletes Supported None
Merge-on-read Supported None
Copy-on-write Not supported Flink writes only delete files.
Compaction Supported Bin-pack strategy only
Z-ordering Not supported None
Transactions Supported Each commit is atomic. A streaming job commits at each checkpoint.
Multi-statement and multi-table transactions Not supported A statement set commits each table separately.
Snapshot isolation Supported None
Serializable isolation Not supported None
Optimistic concurrency control Supported None
Pessimistic concurrency control Not supported None
Table statistics Supported Snapshot summaries only. The summaries are written, but the Flink planner does not get table statistics.
Column statistics Partially supported The minimum, maximum, and null counts of each data file are written to the manifests and used to skip files.
Partition statistics and Puffin statistics Not supported None
Parquet, ORC, and Avro Supported Set the file format with the write.format.default table property.
REST catalog client Supported For more information, see Adding a Cloudera Harmony Catalog.
Views and materialized views Not supported None
Migration from external tables Not supported None
Fine-grained access control (Apache Ranger) Not supported SSB does not apply Ranger policies. For a Cloudera Harmony Catalog, the Ranger policies of the catalog control access to its tables.

A table that you create in a Cloudera Harmony Catalog that you added on the Data Sources page uses format version 3 by default. When you define a table with DDL, the Iceberg library uses format version 2 by default, so set the format-version table property to 3. The following table shows the support for format version 3 features:

Table 2. Iceberg format version 3 feature support
Feature Support Notes
Deletion vectors Supported None
Variant data type Supported Parquet only
Timestamp with nanosecond precision and time zone Supported Maps to the Flink TIMESTAMP_LTZ(9) type.
Unknown data type Supported Read only. Columns of this type are read as NULL.
Default values of columns Partially supported Reads fill in the initial default of missing columns. Writes do not apply the write default.
Row lineage Not supported None
Geometry and geography data types Not supported None
Table encryption Not supported None

Requirements

Streaming writes need checkpointing, because Iceberg commits its data at each checkpoint. Without checkpointing, a job does not write the data. Turn on Enable Checkpointing in the job settings. The default interval is 10 minutes. To set a different interval, run the following statement in the job before the INSERT statement:

SET 'execution.checkpointing.interval' = '10s';

Configure storage for checkpoints and savepoints, because a job needs it to commit data at checkpoints. For more information, see Checkpoints and savepoints.

Create a table in an Iceberg catalog

  1. In the Streaming SQL Console, click Projects in the left navigation pane, and click the name of your project.

    The project opens, with the Explorer panel on the left. To open the Streaming SQL Console, see Accessing Cloudera SQL Stream Builder.

  2. Add an Iceberg catalog, if you have not. For more information, see Adding an Iceberg catalog.
  3. In the Explorer, open the menu of Jobs, and click New Job.
  4. Enter a Job Name, and click Create.
  5. Enter the following statements. Replace the names with yours.
    SET 'execution.checkpointing.interval' = '10s';
    
    CREATE TABLE `my_iceberg_catalog`.`default`.`events` (
      id BIGINT,
      name STRING
    );
    
    INSERT INTO `my_iceberg_catalog`.`default`.`events`
    SELECT id, name FROM my_kafka_table;
  6. Click the Execute job icon.

Create a table with DDL

You can also define the table directly, with the Hive configuration that the Cloudera Base Connector provides at /etc/hive/conf.

CREATE TABLE iceberg_events (
  id BIGINT,
  name STRING
) WITH (
  'connector' = 'iceberg',
  'catalog-type' = 'hive',
  'catalog-name' = 'my_iceberg',
  'catalog-database' = 'default',
  'catalog-table' = 'events',
  'hive-conf-dir' = '/etc/hive/conf'
);
Table 3. Iceberg table options
Option Description
connector Must be iceberg.
catalog-type The backing catalog type: hadoop, hive, or rest.
catalog-name A name for the catalog.
catalog-database The database of the table.
catalog-table The name of the table.
hive-conf-dir The directory with the Hive configuration.