Skip to content

[1048] Convert Avro local timestamps to timestamps without time zone - #19

Draft
yihua wants to merge 2 commits into
ptf-review-build-upgradefrom
ptf-review-avro-local-timestamps
Draft

yihua wants to merge 2 commits into
ptf-review-build-upgradefrom
ptf-review-avro-local-timestamps

Conversation

@yihua

@yihua yihua commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Important Read

Issue: apache#1048, part of apache#722. Based on #8; 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. The commits marked self-review below fix what review of this slice found; they are not on iceberg-v3-ptf-poc yet.

What is the purpose of the pull request

Avro local-timestamp-millis and local-timestamp-micros convert to TIMESTAMP_NTZ with their precision instead of LONG, since Hudi 1.x writes them as Parquet timestamps not adjusted to UTC and Iceberg reads of such tables failed with a ClassCastException.

Brief change log

  • AvroSchemaConverter maps both logical types to TIMESTAMP_NTZ.
  • The comparison helpers of ITIcebergTableFormat and ITConversionController read these columns as timestamps from Hudi and Iceberg.
  • Second commit (self-review): the Delta target goes through the same comparison, since it now writes these columns as TIMESTAMP_NTZ; without it, the 34 Hudi to Delta cases of ITConversionController compared epoch numbers with timestamps of the same instants.

Known limitations:

  • breaking for existing synced tables: an Iceberg target that synced the column as long cannot promote it to timestamp, and a Delta target likely needs the timestampNtz table feature.
  • Hudi 0.x files store these columns as plain INT64, which Iceberg reads as micros, so millisecond values come back wrong.

Verify this pull request

This change added tests and can be verified as follows:

  • TestAvroSchemaConverter expects the new type, and a new case in TestHudiSchemaExtractor converts a Hudi schema with both logical types to the internal schema and on to Iceberg. ITConversionController and ITIcebergTableFormat compare the columns across formats.
  • Run locally on JDK 17 at this PR's level: 582 xtable-core unit tests pass, all 80 ITConversionController cases pass with the self-review commit (34 Hudi to Delta cases failed without it), and the Iceberg table format's 26 unit tests and 46 ITs pass (1 skipped). ITConversionController ran with at most four concurrent cases, which [902] Build on Java 17, Spark 3.5, Iceberg 1.12 and Hudi 1.3.0-SNAPSHOT, with a Spark 4.1 profile #8 now sets for xtable-core, on the default 1.5 GB test heap.

Avro's local-timestamp-millis and local-timestamp-micros were converted to
LONG, since Hudi 0.x wrote them to Parquet as plain INT64. Hudi 1.x writes
them as Parquet timestamps that are not adjusted to UTC. The Iceberg
schema of a table with a TIMESTAMP_NTZ column therefore said long for a
column whose files hold a timestamp, and every Iceberg read of the table
failed with a ClassCastException from LongType to TimestampType.

Both logical types now convert to TIMESTAMP_NTZ and keep their precision,
which the Iceberg schema extractor already turns into a timestamp without
zone.

TestAvroSchemaConverter expects the new type, and a new case in
TestHudiSchemaExtractor converts a Hudi schema with both logical types to
the internal schema and on to Iceberg. The helpers of ITIcebergTableFormat
and ITConversionController that pick the columns to compare read these
columns from Iceberg as longs and now read them as timestamps, as they do
from Hudi.
The Delta target now writes Hudi's local timestamp columns as
TIMESTAMP_NTZ, while the comparison in ITConversionController converted
them to epoch values for Hudi and Iceberg only, so every Hudi to Delta
comparison of these columns compared epoch numbers with timestamps of the
same instants. The Delta side now goes through the same conversion.
@yihua
yihua force-pushed the ptf-review-avro-local-timestamps branch from 4125a7b to 6161978 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