Skip to content

[1059] Write Iceberg timestamp stats in micros for millisecond columns - #1060

Open
the-other-tim-brown wants to merge 3 commits into
apache:mainfrom
the-other-tim-brown:fix/iceberg-millis-timestamp-stats
Open

the-other-tim-brown wants to merge 3 commits into
apache:mainfrom
the-other-tim-brown:fix/iceberg-millis-timestamp-stats

Conversation

@the-other-tim-brown

@the-other-tim-brown the-other-tim-brown commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1059

What is the purpose of the pull request

The Iceberg target wrote the column stats of millisecond timestamp columns as if they were micros, so the lower and upper bounds landed in January 1970 and Iceberg could skip data files with matching rows. This PR converts millis to micros before writing the bounds. It is the same bug #1018 fixes for the Delta Kernel target.

Brief change log

  • IcebergColumnStatsConverter: TIMESTAMP and TIMESTAMP_NTZ bounds are converted to micros when the field's TIMESTAMP_PRECISION is MILLIS. Partition values already did this.
  • TestIcebergColumnStatsConverter#testTimestampBoundsUseFieldPrecision: bounds for TIMESTAMP and TIMESTAMP_NTZ, with millis and micros precision.
  • GenericTable#getTimestampColumn: a timestamp column for each test table.
  • ITConversionController#testVariousOperations: also checks that a filtered read on that timestamp column returns the same rows from every target as from the source. It runs for the Hudi, Delta, Iceberg and Paimon sources.

The Hudi to Iceberg case is skipped for the timestamp filter. Even with correct manifest bounds, Iceberg's Parquet row-group filter compares Hudi's raw TIMESTAMP_MILLIS footer stats with micros literals and prunes every row group, so the read returns 0 rows: apache/iceberg#18173, with a fix in review in apache/iceberg#18321. The skip can be removed once XTable uses an Iceberg release with that fix.

Verify this pull request

This change added tests and can be verified as follows:

  • TestIcebergColumnStatsConverter#testTimestampBoundsUseFieldPrecision fails on main (ts_millis ==> expected: <1710498030123000> but was: <1710498030123>) and passes with the fix.
  • ITConversionController#testVariousOperations: 28 run, 0 failures.
  • ITConversionController#testVariousOperationsDeltaKernelTarget, which shares the timestamp filter with testVariousOperations after merging [1017] Write Delta Kernel timestamp stats in micros for millisecond columns #1018: 4 run, 0 failures.

Tables already written by the Iceberg target keep the old bounds on files that were already synced. A full sync only adds and removes changed files, so deleting the target Iceberg metadata directory and running a full sync rewrites them.

IcebergColumnStatsConverter passed timestamp stats to Iceberg as-is, but
Iceberg bounds are micros and millisecond columns have millis stats, so
the bounds landed in 1970. Convert by TIMESTAMP_PRECISION.

testVariousOperations now also checks a filtered read on a timestamp
column. The Hudi to Iceberg case is skipped because Iceberg's Parquet
row-group filter misreads millis footer stats (apache/iceberg#18173).

This branch has not been deployed

No deployments
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.

Iceberg target writes millisecond timestamp stats as micros, so bounds land in 1970

1 participant