Skip to main content

SQL tables over the lake's files,
with transactions and an evolving schema.

Apache Iceberg is an open table format: it organizes data files as a SQL table, with always-consistent reads, multiple concurrent writers, and safe schema and partition evolution, in any engine that implements it. See what happens in a commit and how a read reaches only the files that matter.

An open table format makes a set of data files work as a SQL table that multiple engines read and write.

Apache Iceberg is one of the TDP table formats, alongside Delta Lake.

Files, not directories

The table knows which files it has

Each data file is recorded in the table metadata. With no reliance on listing directories or renaming files, the table works on top of any object store.

One write, one version

All or nothing

Each write creates a new snapshot and is published by an atomic swap. Readers never see a partial or uncommitted change.

Multiple engines

A common data layer

Spark, Trino, Flink, Hive, and other engines that use the same catalog share the same tables.

On this page

Watch a commit happen​

A write in Spark and a read in Trino, on the same table. Press Play or step through one at a time. Underlined names lead to the Glossary.

EnginesWho writes and who reads
SparkWrites new rows
TrinoReads the table
CatalogWho points to the current version
CatalogPointer to the current metadata file
Metadata layerWhat describes the table
Metadata fileSchema, partitioning, and snapshots
Manifest listThe manifests of a snapshot
Manifest fileData files and statistics
Data layerWhere the rows live
Existing filesAlready part of the table
New filesWritten for this commit
Step 1 of 7

1 Spark loads the table

Before writing, Spark asks the catalog for the table db1.table1 and receives the location of the current metadata file. The change will be built on top of this version.

  1. Spark loads the table. Before writing, Spark asks the catalog for the table db1.table1 and receives the location of the current metadata file. The change will be built on top of this version.
  2. The data files are written. Spark writes the new rows to data files, directly in their final location in storage. For now, no reader sees them: a file only joins the table in an explicit commit.
  3. A manifest records the new files. A new manifest file lists the newly written files, with the partition values and the column statistics of each one.
  4. The manifest list builds the snapshot. A new manifest list gathers the new manifest and the manifests that already existed, reused without being rewritten. It defines the content of the new snapshot: the existing files plus the new ones.
  5. A new metadata file. Spark writes a new metadata file, based on the current one, with the new snapshot as the table's current snapshot. The previous snapshots remain recorded.
  6. The commit: the pointer swaps in one step. Spark asks the catalog to swap the pointer from the metadata file it was based on to the new one. The swap is atomic: either the whole table moves to the new version, or nothing changes. If another writer committed first, the swap fails and Spark redoes the change on top of the current version.
  7. Readers see a whole version. Trino loads the table through the catalog and reads the current snapshot, without locks. A read that started before the commit stays on the previous snapshot until it reloads the table, and that snapshot remains available for time travel until it is expired.
Figure 1 - A commit in Iceberg. The new files and metadata are written first. The change only takes effect when the catalog swaps the pointer.

Architecture​

A catalog, a tree-shaped metadata layer, and a data layer.

Apache Iceberg architecture: catalog, metadata layer and data layerThe catalog holds, for the table db1.table1, the pointer to the current metadata file. In the metadata layer, each metadata file records the table snapshots: the previous one has snapshot s0, and the current one has s0 and s1. Each snapshot points to a manifest list, and the manifest lists point to the manifest files; a single manifest file can serve more than one snapshot. In the data layer, each manifest file points to a set of data files.Catalogdb1.table1pointer to the current metadata fileMETADATA LAYERDATA LAYERmetadata filemetadata filepreviouscurrents0s0s1manifestlistmanifestlistmanifestfilemanifestfilemanifestfiledatafilesdatafilesdatafiles
Figure 2 - Apache Iceberg architecture: the catalog points to the current metadata file, which leads to the snapshots, manifest lists, manifest files, and data files. Underlined terms lead to the Glossary.

What the figure shows:

  1. The catalog keeps, for each table, a pointer: the location of the current metadata file. In the figure, the pointer of db1.table1 points to the current metadata file.
  2. The metadata file, in JSON, records the table's schema, partitioning, and snapshots. In the figure, the previous file has snapshot s0, and the current one has s0 and s1.
  3. The manifest list: each snapshot points to a manifest list, which points to the manifest files.
  4. The manifest files point to the data files. A single manifest can serve several snapshots: in the figure, snapshot s1 reuses part of the s0 tree, which is how each write avoids rewriting the metadata that did not change.
  5. The data files live in the data layer. In the figure, each manifest file points to a set of data files.

From query to file​

A query filters by a date. At each level of the tree, Iceberg discards what cannot contain the answer.

Level 1 of 5

Catalog

The starting point. From the table name, the catalog returns the location of the current metadata file, without any directory needing to be listed.

  1. Catalog. The starting point. From the table name, the catalog returns the location of the current metadata file, without any directory needing to be listed.
  2. Metadata file. Holds the schema, the partition spec, and the current snapshot. With the spec, the query filter on a data column is converted into a partition filter.
    • Partition spec. Says how each partition value is produced from a column, such as day(ts), which gives the date of a timestamp.
  3. Manifest list. For each manifest in the snapshot, it keeps the file count and a summary of the partition values. Manifests that cannot have rows matching the filter are not even opened.
  4. Manifest file. For each data file, it keeps the partition values and the column statistics. Files that cannot contain rows that satisfy the filter are left out of the read.
    • Partition values. The same for all rows in a given data file, which makes it safe to discard the whole file.
  5. Data file. Only the remaining files are read. The engine finds the rows of the answer without having scanned the entire table.
Figure 3 - From query to file: each level leads to the next and discards what does not matter. The partition spec and the statistics accompany the levels.

This discarding is the effect of hidden partitioning.

On an events table partitioned by day(ts), a query with ts > X becomes, at planning time, the partition filter ts_day >= day(X), which selects the files that may have matching rows.

The person querying writes only the filter on ts. Iceberg produces the partition values at write time, always the same way.

A table that changes without being rewritten​

Schema, partitioning, and versions change in the metadata. The data files stay where they are.

Schema evolution

Columns can be added, dropped, renamed, reordered, or have their type widened, including in nested structures, without rewriting data files. Each column has a unique ID, so a new column never reads values from another. See Schema evolution.

Partition evolution

The partition layout changes on an existing table: old data stays as it was, new data follows the new layout, and each layout plans its files with the filter that fits it. A table partitioned by month can become partitioned by day without a migration. See Partition evolution.

Time travel and rollback

A query reads the table at a snapshot or at a point in time, with VERSION AS OF and TIMESTAMP AS OF, and the table can go back to a valid snapshot when a job writes bad data. Retention defines how far back this reaches. See Versions and time travel.

Branches and tags

Named references to snapshots, with their own lifecycle: a tag keeps a historical snapshot for auditing, and a branch isolates a lineage of snapshots to test and validate new jobs. See Branch and tag.

Queryable history

A table's history, snapshots, and manifests can be read as metadata tables, by the table name followed by the metadata table name, such as db.table.history.

Why Iceberg​

Isolation

Always-consistent reads

Table changes are atomic and form a linear history, and readers use a consistent snapshot without blocking anyone.

Concurrency

Multiple writers at the same time

With optimistic concurrency, the writer that loses the race retries on top of the current state, so compatible updates are committed even when writes conflict.

Planning

Fast, without a distributed engine

Finding the files for a read does not require a distributed SQL engine, and partition and column statistics discard the files that do not matter.

Storage

Objects or HDFS

Designed for cloud object stores, it works with any of them and, on HDFS, reduces the load on the NameNode by avoiding listings and renames.

No surprises

Safe schema and partitioning

Schema evolution does not bring back deleted data, and the person querying does not need to know the partitioning to get fast queries.

Open standard

One specification, many implementations

Developed at the Apache Software Foundation, with a specification that ensures compatibility across languages and implementations.

Where it comes from

Iceberg was initially developed at Netflix. The project entered the Apache Software Foundation incubator in 2018 and completed incubation in 2020.

In the TDP editions​

Available in the TDP editions
EditionVersionDocumentation
TDP Datacenter1.8.0TDP Datacenter components
TDP Kubernetes1.10.1 · chart tdp-iceberg 3.0.3Configuration in TDP Kubernetes

In TDP Datacenter​

In TDP Datacenter, Iceberg tables are read and written by the Spark3, Trino, and Hive services, and support for the format lives in the configuration of each one, in Ambari. NiFi provides processors for the format.

Catalogs in Spark3

In spark3-defaults, spark.sql.catalog.spark_catalog adds Iceberg tables to Spark's built-in catalog, and spark.sql.catalog.tdp_catalog defines an Iceberg catalog with its own name. The Iceberg SQL extensions, such as the procedures called by CALL, go in spark.sql.extensions. See Apache Spark.

Catalog implementation

The tdp_catalog implementation is chosen in spark.sql.catalog.tdp_catalog.type (hadoop, hive, or rest), with the catalog address in spark.sql.catalog.tdp_catalog.uri and the table location in spark.sql.catalog.tdp_catalog.warehouse.

Trino connector

The Iceberg connector can be enabled in use.iceberg, in the connectors-properties configuration. Trino's iceberg catalog uses the metastore address defined in spark.sql.catalog.tdp_catalog.uri. See Trino.

Hive support

The Iceberg runtime library goes into Hive's auxiliary classpath, in hive-env, and Hive's support for Iceberg tables is configurable in iceberg.engine.hive.enabled, in the hive-site configuration. See Apache Hive.

In TDP Kubernetes​

In TDP Kubernetes, the tdp-iceberg chart delivers scheduled maintenance jobs for Iceberg tables, with Spark as the runtime.

Maintenance jobs

Snapshot expiration, orphan file removal, and data file rewriting, in maintenance.jobs.*. Each job is enabled in enabled, has its schedule in schedule, and processes the tables listed in tables or, with an empty list, all Iceberg tables in the catalog. Rewriting data files comes disabled. The role of each job is described in Scheduled maintenance.

Spark runtime

Each job runs Spark in its own pod, with the image defined in maintenance.spark.image.*, which already includes the Iceberg, S3, and Hive Metastore jars. The jobs do not need a Spark cluster. The chart can also bring up its own Spark cluster through the spark subchart, in spark.enabled, off by default and not used by the jobs.

Catalog

By default, the jobs' Iceberg catalog is the Hive Metastore, in spark.sql.catalog.iceberg.type and spark.sql.catalog.iceberg.uri, adjustable in maintenance.spark.config. See Hive Metastore.

Storage

S3-compatible, through the S3A endpoint in maintenance.spark.config. Credentials arrive through the s3-credentials Secret, with the access-key and secret-key keys.

Who reads and writes the tables

Spark, with the optional tdp-spark.iceberg.enabled block and the Iceberg properties in the Spark configuration, and Trino, with an iceberg catalog in tdp-trino.catalogs pointing to the Hive Metastore and to S3-compatible storage. See Where Spark and Trino find the tables. In Python, PyIceberg, in the Spark and JupyterLab images, reaches the same Hive Metastore as Spark's Iceberg catalog.

Next steps​

Sources​

Apache Iceberg - Documentation

Apache Iceberg - Table Spec

Apache Iceberg - Terms

Apache Iceberg - Reliability

Apache Iceberg - Partitioning

Apache Iceberg - Evolution

Apache Iceberg - Branching and Tagging

Apache Iceberg - Spark Queries