Skip to content

[1017] Write Delta Kernel timestamp stats in micros for millisecond columns - #1018

Merged
the-other-tim-brown merged 7 commits into
apache:mainfrom
Indian-boult:fix/kernel-ts-stats
Nov 28, 2026
Merged

the-other-tim-brown merged 7 commits into
apache:mainfrom
Indian-boult:fix/kernel-ts-stats

Conversation

@Indian-boult

@Indian-boult Indian-boult commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1017

What is the purpose of the pull request

The Delta Kernel target wrote the column stats of millisecond timestamp columns as if they were micros, so min and max landed in January 1970. Delta readers skip files using those stats, so a filter on the column returned no rows. This PR converts millis to micros before building the Kernel literal, as the Delta Standalone target already does. Part of the work before Kernel becomes the default Delta target (#886).

Brief change log

  • DeltaKernelDataFileUpdatesExtractor: TIMESTAMP and TIMESTAMP_NTZ stats are converted to micros when the field's TIMESTAMP_PRECISION is MILLIS. Other precisions are unchanged.
  • TestDeltaKernelDataFileUpdatesExtractor#testTimestampStatsUseFieldPrecision: min and max for TIMESTAMP and TIMESTAMP_NTZ, with millis and micros precision, compared with the expected instants and with the Standalone stats.
  • ITConversionController#testVariousOperationsDeltaKernelTarget also checks a filter on the Hudi table's timestamp-millis column, so a filtered Spark Delta read on that column must return the same rows as the source.

Verify this pull request

This change added tests and can be verified as follows:

  • TestDeltaKernelDataFileUpdatesExtractor#testTimestampStatsUseFieldPrecision fails on main (Kernel minValues.ts_millis was 1970-01-20T19:08:18.030Z) and passes with the fix.
  • ITConversionController#testVariousOperationsDeltaKernelTarget fails on main in all four cases at the new filter check, with 57 rows from the source and 0 from the Kernel target, and passes with the fix.
  • ./mvnw -pl xtable-core test runs 597 tests with 0 failures and 3 skipped.
  • ITDeltaKernelConversionSource and ITConversionController passed on the earlier commits, and the four testVariousOperationsDeltaKernelTarget cases pass on the latest one.

Tables already written by the Kernel target keep the old stats on files that were already synced. Deleting the target _delta_log and running a full sync rewrites them.

…olumns

XTable stores TIMESTAMP and TIMESTAMP_NTZ column stats as millis or
micros since epoch, depending on the field's TIMESTAMP_PRECISION.
DeltaKernelDataFileUpdatesExtractor passed the value to Kernel's
timestamp literals, which take micros, without checking the precision.
For a millisecond column, such as a Hudi timestamp-millis field, the
Kernel target wrote min and max 1000 times too small, in January 1970.
Delta readers skip files with these stats, so a filter on the column
returned no rows. The Standalone target already converts by precision.
Convert millis to micros before building the literal.

Fixes apache#1017
So the tests also compile once apache#1012 makes numNulls Long.
Resolves the import conflict with apache#1012 in TestDeltaKernelDataFileUpdatesExtractor by keeping both the JsonNode and ObjectMapper imports.
…re one ObjectMapper

Check the timestamp-millis filter in testVariousOperationsDeltaKernelTarget
instead of a separate IT, and use one ObjectMapper for the test class.
@the-other-tim-brown

Copy link
Copy Markdown
Contributor

Thanks @Indian-boult

@the-other-tim-brown
the-other-tim-brown merged commit ed4be71 into apache:main Nov 28, 2026
8 checks passed
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.

Delta Kernel target writes millisecond timestamp column stats as micros

2 participants