Moving 7,000 tables to Apache Iceberg

·

Between mid-2024 and mid-2025 we moved our Hadoop data platform from Hive-style Parquet tables to Apache Iceberg: around 7,000 tables, written by Spark jobs and read mostly through Trino. It took about a year, and it is the kind of project where the format itself is the easy part. This post is about the rest: how we rolled it out, the Iceberg behaviours that surprised us, the patches we ended up carrying, and the one migration batch that broke things for another team.

Why Iceberg

Our reasons were the usual ones, but each mapped to a real problem we had:

  • Hidden partitioning. Iceberg derives partition values from columns and prunes partitions from ordinary filters. Our users no longer need to know a table’s partition column and remember to filter on it.
  • Row-level operations. Upserts and deletes without rewriting a whole table or partition.
  • Snapshots. Time travel, rollback, and branches and tags on a table, so a bad write can be undone instead of rebuilt.
  • Safe concurrent writes. Iceberg commits are optimistic and atomic, which matters for tables that several jobs write to.

Rolling it out one write pattern at a time

Almost all of our tables are written through a single transformation framework, where each job picks a write pattern: replace the whole table, append, rewrite recent partitions, and so on. That gave us the unit of migration. For each pattern we built an Iceberg equivalent, migrated the jobs using it, and watched production before moving on:

  • Full replace for snapshots of source databases and other small tables.
  • Append for tables that only grow.
  • Incremental partitioned for event tables that rewrite recent days, including automatic backfills.
  • Upsert keyed on a primary key, which our Parquet tables couldn’t do at all.

Because the pattern was declared in code, migrating a job was usually a one-line change, and the framework took care of partition specs, table properties and maintenance. Within each pattern we moved one database first and the rest in batches. Our own operational tables went first, then ingestion jobs, then the SQL-based transformations, and the most user-facing tables last.

One constraint we hadn’t planned for was disk. We kept the old Hive copy of each migrated table until we were confident in the new one, so the migration temporarily doubled the storage of everything in flight, and we had to slow down the batches until space was freed.

Iceberg behaviours that surprised us

DROP TABLE doesn’t delete your data

In our setup, Iceberg tables behave like external tables: DROP TABLE removes the table from the catalog and leaves its files on HDFS. You need DROP TABLE ... PURGE to delete the data, and even then the empty data/ and metadata/ directories, plus one empty directory per partition, stay behind. That surprises anyone used to Hive managed tables.

RENAME doesn’t move files

Renaming an Iceberg table changes its name in the catalog, while its files stay where they were. Rename a to b, create a new a, and two tables can end up sharing a directory. After that you can’t tell which table owns a directory without reading Iceberg metadata, and our cleanup and audit tooling worked from directories. We disabled renames of Iceberg tables and tell users to create, copy and purge instead. Later we went further and patched Iceberg so that any explicit LOCATION must follow the <db>.db/<table> layout, on every create, CTAS, replace and ALTER TABLE SET LOCATION.

Concurrent writers need more than optimistic commits

Some of our metrics tables are written by many jobs at once. Optimistic concurrency means conflicting commits have to retry. We started with application-level retries and then added ZooKeeper-based locks, but parallel writes only became reliable once we disabled Spark’s catalog cache for Iceberg.

Maintenance is your job now

Every commit adds metadata files and snapshots, and frequent small writes add small data files. By default Iceberg keeps the previous 100 metadata files; we found tables with more than 100 files in their metadata/ directory and dropped that to 4. Compaction and snapshot cleanup run as a separate asynchronous job, the same way we already ran table statistics, so a write job never waits on table maintenance.

Timestamps change type

Spark’s default TIMESTAMP is timezone-aware, and Iceberg stores it as timestamptz. The same column that was a plain timestamp in a Parquet table came back as timestamp with time zone from Trino after migration. Trino handles the two together without complaint, and our values are all UTC anyway, but one of our Python clients failed on mixing timezone-naive and timezone-aware datetimes. Trino views over migrated tables had their own timestamp bugs, which comes up again below.

Permissions move to the catalog

With Parquet tables, HDFS permissions decided who could delete a table’s data. With Iceberg, DROP TABLE goes through the catalog, so users could drop tables whose files they could never have deleted themselves. We patched Iceberg’s Spark integration to check HDFS delete permission first, mirroring the NameNode’s own rules including sticky directories. It fails open when a table’s metadata is missing or unreadable, so broken tables can still be cleaned up, and it exempts the service accounts that manage pipeline tables.

Carrying patches on Iceberg

Both guards live in our fork of Iceberg, applied to the Spark 3.4, 3.5 and 4.0 integrations, with unit and integration tests for each. The cluster’s build fetches the patch commit from the fork, verifies its checksum and applies it on top of the release, which replaced a 1,400-line patch file we used to keep in the infrastructure repo. Each Iceberg upgrade (we went from 1.6 to 1.11 since we started) means rebasing the patches and re-running their tests. A smaller patch is a cheaper upgrade, so we keep them narrow.

The batch that broke another team’s reports

Most of the migration was uneventful. In March 2025 we switched a batch of SQL-based tables to Iceberg, and a team’s reports built on those tables started failing. Their Trino views ran into a Trino bug with timestamps in views over Iceberg tables. We had checked our jobs and the migrated tables, but not the views other teams had built on top of them. The switch also landed in the first week of the month, when that team produces its monthly reports.

We were migrating 7,000 tables, so a batch of 100 felt like a small, careful step. For that team, those 100 tables were their whole database, and the change reached them all at once. A gradual rollout for the platform team can be a big-bang change for each of its users. The fix is in how batches get planned: look at each one from the side of the people who query those tables, tell them before it goes out, and keep changes to reporting tables out of the first weeks of the month.

Finishing

Migrating the tables was not the end. In July 2025 we made Iceberg the default table format for Spark and Trino on the cluster, so new tables created by hand also come out as Iceberg. For a year we kept Parquet as the default for pipeline service accounts, for backward compatibility. In 2026 our Python data library stopped writing anything but Iceberg, the last few Parquet tables are being converted, and we dropped the leftover Hive copies.

Today every new table on the cluster starts as Iceberg, and the remaining work is upgrades and table maintenance.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *