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
- Architecture
- From query to file
- A table that changes without being rewritten
- Why Iceberg
- In the TDP editions
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.
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.
In the Glossary: Catalog · Metadata file
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
Architecture
A catalog, a tree-shaped metadata layer, and a data layer.
What the figure shows:
- The catalog keeps, for each table, a pointer: the location of the current metadata file. In the figure, the pointer of
db1.table1points to the current metadata file. - 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.
- The manifest list: each snapshot points to a manifest list, which points to the manifest files.
- 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.
- 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.
- 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.
- 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.
- 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.
- 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.
- Data file. Only the remaining files are read. The engine finds the rows of the answer without having scanned the entire table.
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.
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.
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.
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.
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.
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.
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
| Edition | Version | Documentation |
|---|---|---|
| TDP Datacenter | 1.8.0 | TDP Datacenter components |
| TDP Kubernetes | 1.10.1 · chart tdp-iceberg 3.0.3 | Configuration 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.
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.
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.
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.
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.
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.
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.
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.
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.
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
TDP Kubernetes
Iceberg Configuration
Maintenance jobs, schedules, tables, retention, and resources in the chart.
TDP Datacenter
One catalog for the tables
The same tables available to multiple engines in the cluster managed by Ambari.
Concept
Lakehouse
Iceberg and Delta Lake on top of S3 storage, with transactions, versions, and scheduled maintenance.
Table format
Delta Lake
The other TDP table format, which can coexist with Iceberg in the same environment.
Sources
Apache Iceberg - Documentation