Skip to content

[1044] Leave Hudi's meta columns out of the Iceberg schema of the table format - #18

Draft
yihua wants to merge 2 commits into
ptf-review-row-lineagefrom
ptf-review-meta-columns-out-of-schema
Draft

yihua wants to merge 2 commits into
ptf-review-row-lineagefrom
ptf-review-meta-columns-out-of-schema

Conversation

@yihua

@yihua yihua commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Important Read

Issue: apache#1044, part of apache#722. Based on #13; review that first. The change is already on iceberg-v3-ptf-poc, which is not meant to land as one PR, so this PR carries one area of it for review.

What is the purpose of the pull request

The Iceberg schema of a table published through the table format no longer lists the five _hoodie_* columns; the base files still store them and Iceberg readers skip them through the table's name mapping. The name mapping a commit sets again is built from the table's schema, so the field ids stay right after columns were dropped or added.

Brief change log

Known limitations:

  • regression: a reader that ignores Iceberg's name mapping, such as IcebergGenerics, now reads the wrong columns, since the base files have no field ids and start with the meta columns.
  • A table published before this change drops its meta columns on its next schema sync.

Verify this pull request

This change added tests and can be verified as follows:

  • ITIcebergMetaColumns checks that the Iceberg schema has no meta columns while the base files keep them, that Spark, the Parquet reader and Iceberg's changelog read the right columns through the name mapping, that a restored name mapping keeps the table's field ids after columns were dropped and added, and pins what IcebergGenerics, which ignores the name mapping, reads. TestHudiTableExtractor and TestIcebergSync cover the flag and the mapping.
  • Run locally on JDK 17 at this PR's level: 607 xtable-core unit tests and 9 xtable-core Iceberg ITs pass, and the Iceberg table format's 43 unit tests and 136 ITs pass (1 skipped).

The schema sync collects its updates in a map by field id and put every
dropped column under the key 0, so that drops run first. When one sync
removed several columns, each drop replaced the one before it in the map
and a single column was dropped. The others stayed in the Iceberg schema
and were dropped one per later sync.

A drop is now keyed by the negative field id of its column, which still
runs the drops first and keeps one entry per column. A new test removes
two columns in one sync and expects both to be dropped.
A table published through the Iceberg table format listed
_hoodie_commit_time, _hoodie_commit_seqno, _hoodie_record_key,
_hoodie_partition_path and _hoodie_file_name as its first five columns.
Iceberg readers saw columns no Iceberg writer has, and a row that a rewrite
carried over unchanged differed from its earlier version in
_hoodie_file_name, so Iceberg's changelog view reported it as updated.

The table format now describes the table without the meta columns.
HudiTableExtractor takes a flag for it, which only the table format sets,
so every other conversion from Hudi keeps the columns. There is no setting,
since nothing in the format reads the columns through the Iceberg schema:
stats, partition values, positional deletes and the row lineage checks read
the base files or Hudi's own schema. The base files still store the
columns. Iceberg readers skip them, as Hudi's base files carry no field ids
and are read through the table's default name mapping, which maps the
columns of the schema and, at format version 3, the row lineage columns
under their reserved ids.

The name mapping was already set by the first commit of a table and set
again by a commit that finds it missing, without any setting. A mapping set
again was built from the converted source schema, though. That schema
numbers the columns of a source without field ids in order, which differs
from the field ids of the table once a column was dropped or added, so the
columns after it were mapped to the ids of other columns. The mapping is
now built from the schema of the table, and the schema update that follows
maintains it.

A reader that ignores the name mapping, as Iceberg's IcebergGenerics does,
resolves the columns of a file without field ids by position. It used to
read the right top-level columns by coincidence and now reads
_hoodie_commit_time as the first column of the table. A test pins this
limit.

The new tests read a copy-on-write table and a merge-on-read table with
deletion vectors through Spark, and check the name mapping after the first
commit at format versions 2 and 3, after its removal, after added top-level
and nested columns, and after two columns dropped in one commit followed by
an added column, as well as the row lineage columns of a rewritten base
file. The test helpers that read the meta columns through Iceberg now read
them through Hudi or from the base files.
@yihua
yihua force-pushed the ptf-review-row-lineage branch from 81f8862 to 2532a6e Compare November 24, 2026 20:56
@yihua
yihua force-pushed the ptf-review-meta-columns-out-of-schema branch from 2a807b6 to fcb0200 Compare November 24, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant