All posts

Apache XTable: Delta, Paimon and Parquet sources and their traps

Delta needs nothing, a Paimon primary-key table converts only compacted files and can sync with zero rows, and Parquet is rejected until a converters config names its provider.

8 min read Lakehouse

TL;DR

The three sources describe a table in three different ways: Delta with a transaction log, Paimon with LSM-tree snapshots, and Parquet with no table metadata at all. XTable reads each one differently, and each has one thing to do before the first sync.

Everything else follows from that sentence:

  • Delta needs nothing. The log is the table, and the second sync ran incrementally with no fallback line.
  • Delta Kernel is a second Delta implementation, picked with a converters config in RunSync and chosen automatically by the Spark runtime on newer Spark versions. As a target it cannot evolve an existing table’s schema and cannot write generated columns, so use RunSync’s default Delta target for those.
  • Paimon is a source only, and a primary-key table converts only its compacted files. A fresh table synced with a success line and zero rows, and compacting first converted all three.
  • Parquet is not in the defaults file, so RunSync rejects it until a converters config names its provider. The Spark runtime jar takes it directly.
  • Paimon and Parquet cannot be targets. Delta can.

The Hudi and Iceberg sources have their own posts, because both have a lot of behaviour of their own. These three are shorter, and what they share is that the table format says little about what the files mean. The answers below were checked on 0.5.0-incubating. The build and every flag are in the cheat sheet.

Delta reads its transaction log and needs nothing first, Paimon needs a primary-key table compacted first, and Parquet needs a converters config because RunSync does not list it

Delta as a source

A Delta table converts with the defaults. This ran on Spark 3.5.9 with delta-spark 3.3.2, which reads the log the Delta target writes:

trips = spark.createDataFrame(
    [("trip-%d" % (1001 + i), "rider-%d" % (10 + i % 5), round(10 + i * 7.25, 2),
      1758000000 + i * 60, ["sf", "nyc"][i % 2]) for i in range(4)],
    ["trip_id", "rider_id", "fare_amount", "updated_at", "city_id"])

trips.write.format("delta").mode("overwrite").save("file:///tmp/lakehouse/trips_delta")

Save this as delta_sync.yaml. There is no partitionSpec because the table is not partitioned:

sourceFormat: DELTA
targetFormats:
  - ICEBERG
  - HUDI
datasets:
  - tableBasePath: file:///tmp/lakehouse/trips_delta
    tableName: trips_delta
java -jar "$XTABLE_JAR" --datasetConfig delta_sync.yaml
INFO  ConversionController:215 - Sync is successful for the following formats HUDI,ICEBERG

The directory then holds _delta_log, .hoodie and metadata beside the Parquet files. Appending two rows with Delta and syncing again printed only the success line, with no Falling back to snapshot sync line, so the second run was incremental. Iceberg and Hudi both returned six rows.

Three documented caveats apply to a Delta source:

Caveat What to do
Converting to Iceberg may need field IDs Enable column mapping on the Delta table
Generated columns are not synced to the target schema Partitioning on a generated column is only partly supported
Column stats are not read by physical name when column mapping is on Fixed on the development branch after 0.5.0, so not in it. Check the next release before working around it

Delta Kernel. 0.5.0 has a second Delta implementation in org.apache.xtable.kernel. Select it by naming its classes in a converters config and passing that to RunSync with --convertersConfig:

tableFormatConverters:
  DELTA:
    conversionSourceProviderClass: org.apache.xtable.kernel.DeltaKernelConversionSourceProvider
    conversionTargetProviderClass: org.apache.xtable.kernel.DeltaKernelConversionTarget
    configuration:
      spark.master: local[2]
      spark.app.name: xtable

A Hudi table synced to Delta this way wrote one commit, 00000000000000000000.json, and Spark read the same three rows from it. Only the Kernel target was tested, and it has two limits. It cannot create the generated columns that time and bucket partitions need, and it cannot evolve the schema of an existing Delta table: after a column was added to an Iceberg source, the second sync through the Spark runtime failed with Schema evolution on an existing Delta table is not supported by DeltaKernelConversionTarget, while RunSync’s default target synced the same table. The Kernel source was not tested. The Spark runtime jar picks Kernel by itself on Spark 3.5 and newer, which is why it needs io.delta:delta-kernel-api and delta-kernel-defaults 4.0.0 on the classpath.

Paimon as a source

Paimon is a source only. No Paimon target is registered, so a Paimon table can become Hudi, Iceberg or Delta, and nothing converts back.

A fresh primary-key Paimon table has files at level 0, which XTable skips, so it converts only after compaction moves them to the top level

The catch is the primary-key table. XTable reads only the top level of the LSM tree, which means fully compacted files. A fresh primary-key table written by Spark has everything at level 0. This table was created with paimon-spark-3.5 1.3.1:

CREATE TABLE pm.db.trips_pm (trip_id STRING, rider_id STRING, fare_amount DOUBLE,
  updated_at BIGINT, city_id STRING)
PARTITIONED BY (city_id)
TBLPROPERTIES ('primary-key'='trip_id,city_id', 'bucket'='2');

INSERT INTO pm.db.trips_pm VALUES
  ('trip-1001','rider-10',10.0,1758000000,'sf'),
  ('trip-1002','rider-11',17.25,1758000060,'nyc'),
  ('trip-1003','rider-12',24.5,1758000120,'sf');
sourceFormat: PAIMON
targetFormats:
  - ICEBERG
  - DELTA
  - HUDI
datasets:
  - tableBasePath: file:///tmp/lakehouse/pm/db.db/trips_pm
    tableName: trips_pm

The sync succeeded for all three targets, and reading them returned nothing:

INFO  ConversionController:215 - Sync is successful for the following formats HUDI,ICEBERG,DELTA
FORMAT iceberg rows 0
FORMAT delta rows 0

After compacting, a sync into fresh target directories converted all three rows:

CALL pm.sys.compact(table => 'db.trips_pm');
FORMAT iceberg rows 3
FORMAT delta rows 3

An append-only Paimon table has no such level, and converted completely at once. So a Paimon sync that logs success is not evidence that rows arrived. Compare counts, as in the validation section of the Hudi source post, and schedule a compaction before the sync for any primary-key table.

Parquet as a source

A plain directory of Parquet files can be a source, but it is not in xtable-conversion-defaults.yaml, and RunSync stops with:

Exception in thread "main" java.lang.IllegalArgumentException: Source format PARQUET
is not supported. Known source and target formats are [HUDI, DELTA, ICEBERG, PAIMON]

Pass a converters config that names the provider and the same directory converts to Iceberg, Delta and Hudi in one run. Save this as conv_parquet.yaml:

tableFormatConverters:
  PARQUET:
    conversionSourceProviderClass: org.apache.xtable.parquet.ParquetConversionSourceProvider
sourceFormat: PARQUET
targetFormats:
  - ICEBERG
  - DELTA
  - HUDI
datasets:
  - tableBasePath: file:///tmp/lakehouse/trips_pq
    tableName: trips_pq
java -jar "$XTABLE_JAR" --datasetConfig parquet_sync.yaml --convertersConfig conv_parquet.yaml
INFO  ConversionController:215 - Sync is successful for the following formats HUDI,ICEBERG,DELTA

Iceberg and Delta each returned the four rows. The Spark runtime jar needs no converters config:

$SPARK_HOME/bin/spark-submit \
  --packages org.apache.iceberg:iceberg-spark-runtime-3.5_2.12:1.9.2,io.delta:delta-spark_2.12:3.3.2,io.delta:delta-kernel-api:4.0.0,io.delta:delta-kernel-defaults:4.0.0 \
  --class org.apache.xtable.spark.XTableSparkSync \
  xtable-spark-runtime_2.12-0.5.0-incubating.jar \
  --basepath file:///tmp/lakehouse/trips_pq \
  --sourceformat PARQUET \
  --targets ICEBERG,DELTA

A Parquet source has no commit log, so the source treats each file’s modification time as its commit time. Incremental sync works from those times: it is safe when the earliest file is not newer than the last synced instant, and all targets must be at the same instant or the run fails with Parquet incremental sync does not support target formats synced to different instants. That behaviour was read from ParquetConversionSource and not run. The docs list two limits. XTable takes the schema from the newest file’s footer and does not merge schemas across files, and a partition column that exists only in a directory name, such as region=eu/, is not supported, so the partition column has to be inside the files. In 0.5.0 the Spark runtime also supports a --partitionspec for a Parquet source.

A Parquet source has no commit log, so file modification times act as commit times and all targets must share one instant

Failures you can hit with these sources

Symptom Cause Fix
Source format PARQUET is not supported. Known source and target formats are [...] Parquet is not in the defaults file Pass --convertersConfig naming ParquetConversionSourceProvider, or use the Spark runtime
Paimon sync succeeds and the target has 0 rows A primary-key table with everything at level 0 Compact first, then sync again
NoClassDefFoundError: io/delta/kernel/engine/Engine in the Spark runtime Delta Kernel jars missing from the classpath Add delta-kernel-api and delta-kernel-defaults 4.0.0
NotSupportedException: Schema evolution on an existing Delta table is not supported by DeltaKernelConversionTarget The Kernel target cannot evolve a schema. This was run: an Iceberg source gained a column and the second sync through the Spark runtime failed Set xtable.delta.target.use_kernel=false, or sync that table with RunSync, whose default Delta target succeeded
NoSuchMethodError: DeltaLog.ensureLogDirectoryExist() The session’s delta-spark 3.3.2 met the older Delta writer Set useDeltaKernel(true) or --usedeltakernel

Key takeaways

None of these sources fails loudly when it fails. The Delta table converts, the Paimon sync logs success on an empty result, and the Parquet directory is refused with a message that sounds like a missing feature rather than a missing file. Do the one step each needs, and compare counts after the first sync.

References

Trademarks

Apache XTable (incubating), Apache Paimon, Apache Iceberg, Apache Hudi, Apache Spark, Apache Parquet and Apache are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries. Delta Lake is a trademark of the Linux Foundation. All other marks are the property of their respective owners.

Found this useful?

These posts and tools are free. If one saved you an afternoon, you can buy me a coffee.

Buy me a coffee

Comments

Questions, corrections and reviews are welcome. Sign in with GitHub to post; comments are stored in this site's public GitHub Discussions.