Skip to content

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

Draft
yihua wants to merge 1 commit into
apache:mainfrom
yihua:xt-1048-avro-local-timestamps
Draft

yihua wants to merge 1 commit into
apache:mainfrom
yihua:xt-1048-avro-local-timestamps

Conversation

@yihua

@yihua yihua commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Important Read

Closes #1048, part of #722.

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, Iceberg and Delta.

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 11: 597 xtable-core unit tests pass (3 skipped), all 80 ITConversionController cases and the xtable-core Iceberg ITs pass, and the Iceberg table format's 26 unit tests and 46 ITs pass (1 skipped).
  • CI: not green yet. ITConversionService in xtable-service keeps its own copy of the comparison helper, which still divides the Iceberg local timestamp columns by 1000 and now fails on TIMESTAMP_NTZ; it needs the same change as ITConversionController. The first run also hit a flaky TestPaimonStatsExtractor case.

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 these columns as TIMESTAMP_NTZ too,
so ITConversionController converts its side the same way.
@yihua yihua closed this Nov 25, 2026
@yihua yihua reopened this Nov 25, 2026

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.

Avro local-timestamp-millis and local-timestamp-micros convert to LONG, so Iceberg reads of Hudi 1.x tables fail

1 participant