Delta Lake Table Migration
Delta Lake is a table format that supports Parquet file format and provides time travel and versioning features. When migrating data from Delta Lake to Iceberg, it is common to migrate all snapshots to maintain the history of the data.
Currently, Iceberg supports the Snapshot Table action for migrating from Delta Lake to Iceberg tables. Since Delta Lake tables maintain transactions, all available transactions will be committed to the new Iceberg table as transactions in order. For Delta Lake tables, any additional data files added after the initial migration will be included in their corresponding transactions and subsequently added to the new Iceberg table using the Add Transaction action. The Add Transaction action, a variant of the Add File action, is still under development.
Enabling Migration from Delta Lake to Iceberg
iceberg-delta-lake module is not bundled with Spark and Flink engine runtimes. To enable migration from delta lake features, the minimum required dependencies are:
The module is built and tested with
Delta Standalone:0.6.0 and supports Delta Lake tables with the following protocol version:
Please refer to Delta Lake Table Protocol Versioning for more details about Delta Lake protocol versions.
iceberg-delta-lake module provides an interface named
DeltaLakeToIcebergMigrationActionsProvider, which contains actions that helps converting from Delta Lake to Iceberg.
The supported actions are:
snapshotDeltaLakeTable: snapshot an existing Delta Lake table to an Iceberg table
iceberg-delta-lake module also provides a default implementation of the interface which can be accessed by
DeltaLakeToIcebergMigrationActionsProvider defaultActions = DeltaLakeToIcebergMigrationActionsProvider.defaultActions()
Snapshot Delta Lake Table to Iceberg
snapshotDeltaLakeTable reads the Delta Lake table’s transactions and converts them to a new Iceberg table with the same schema and partitioning in one iceberg transaction.
The original Delta Lake table remains unchanged.
The newly created table can be changed or written to without affecting the source table, but the snapshot uses the original table’s data files. Existing data files are added to the Iceberg table’s metadata and can be read using a name-to-id mapping created from the original table schema.
When inserts or overwrites run on the snapshot, new files are placed in the snapshot table’s location. The location is default to be the same as that of the source Delta Lake Table. Users can also specify a different location for the snapshot table.
snapshotDeltaLakeTableare not the sole owners of their data files, they are prohibited from actions like
expire_snapshotswhich would physically delete data files. Iceberg deletes, which only effect metadata, are still allowed. In addition, any operations which affect the original data files will disrupt the Snapshot’s integrity. DELETE statements executed against the original Delta Lake table will remove original data files and the
snapshotDeltaLakeTabletable will no longer be able to access them.
|Required Input||Configured By||Description|
|Source Table Location||Argument ||The location of the source Delta Lake table|
|New Iceberg Table Identifier||Configuration API ||The identifier specifies the namespace and table name for the new iceberg table|
|Iceberg Catalog||Configuration API ||The catalog used to create the new iceberg table|
|Hadoop Configuration||Configuration API ||The Hadoop Configuration used to read the source Delta Lake table.|
For detailed usage and other optional configurations, please refer to the SnapshotDeltaLakeTable API
|long||Number of files added to the new table|
Added Table Properties
The following table properties are added to the Iceberg table to be created by default:
|Indicates that the table is snapshot from a delta lake table|
|location of the delta lake table||The absolute path to the location of the original delta lake table|
|JSON name mapping derived from the schema||The name mapping string used to read Delta Lake table’s data files|
import org.apache.iceberg.catalog.TableIdentifier; import org.apache.iceberg.catalog.Catalog; import org.apache.hadoop.conf.Configuration; import org.apache.iceberg.delta.DeltaLakeToIcebergMigrationActionsProvider; String sourceDeltaLakeTableLocation = "s3://my-bucket/delta-table"; String destTableLocation = "s3://my-bucket/iceberg-table"; TableIdentifier destTableIdentifier = TableIdentifier.of("my_db", "my_table"); Catalog icebergCatalog = ...; // Iceberg Catalog fetched from engines like Spark or created via CatalogUtil.loadCatalog Configuration hadoopConf = ...; // Hadoop Configuration fetched from engines like Spark and have proper file system configuration to access the Delta Lake table. DeltaLakeToIcebergMigrationActionsProvider.defaultActions() .snapshotDeltaLakeTable(sourceDeltaLakeTableLocation) .as(destTableIdentifier) .icebergCatalog(icebergCatalog) .tableLocation(destTableLocation) .deltaLakeConfiguration(hadoopConf) .tableProperty("my_property", "my_value") .execute();