Skip to content

[FLINK-39415][postgres] Fix TIMESTAMPTZ type mapping in pipeline connector#4371

Open
avichaym wants to merge 1 commit intoapache:masterfrom
avichaym:fix/timestamptz-iceberg-sink
Open

[FLINK-39415][postgres] Fix TIMESTAMPTZ type mapping in pipeline connector#4371
avichaym wants to merge 1 commit intoapache:masterfrom
avichaym:fix/timestamptz-iceberg-sink

Conversation

@avichaym
Copy link
Copy Markdown

@avichaym avichaym commented Apr 9, 2026

What is the purpose of the change

Fix TIMESTAMPTZ type mapping in the PostgreSQL pipeline connector that causes
NumberFormatException when writing to the Iceberg sink.

PostgresTypeUtils mapped TIMESTAMPTZ to ZonedTimestampType
(TIMESTAMP_WITH_TIME_ZONE), but the Debezium deserializer only produces
LocalZonedTimestampData (TIMESTAMP_WITH_LOCAL_TIME_ZONE). This type
mismatch causes binary data corruption in BinaryRecordData, crashing the
Iceberg sink's IcebergTypeUtils.createFieldGetter() during both snapshot
and CDC phases.

The existing test PostgresFullTypesITCase (line 1211) already expects
TIMESTAMP_LTZ(0) for TIMESTAMPTZ, confirming the correct mapping.

Brief change log

  • PostgresTypeUtils: Map TIMESTAMPTZTIMESTAMP_LTZ(scale) (was ZonedTimestampType)
  • DebeziumEventDeserializationSchema: Add convertToZonedTimestamp() for future TIMESTAMP_WITH_TIME_ZONE support
  • New test: PostgresTypeUtilsTimestamptzTest — validates type mapping
  • IcebergTypeUtilsTest: Add assertions for TIMESTAMP_LTZ type conversion and field getter

Verifying this change

  • New unit tests added (see above)
  • Validated end-to-end on EKS with Flink 1.20 + CDC 3.6.0: TIMESTAMPTZ data written to Apache Iceberg (S3 Tables) with correct microsecond precision

Does this pull request potentially affect one of the following parts

  • Dependencies: no
  • The public API: no
  • The runtime per-record code path: no
  • Anything that affects deployment: no

Documentation

  • Does this pull request introduce a new feature? No (bug fix)

@avichaym avichaym force-pushed the fix/timestamptz-iceberg-sink branch from bdc434b to 23ca01d Compare April 9, 2026 09:30
@avichaym avichaym force-pushed the fix/timestamptz-iceberg-sink branch 3 times, most recently from 5336d69 to e8d1f25 Compare April 9, 2026 13:14
…ector

Root cause: PostgresTypeUtils (pipeline connector) mapped TIMESTAMPTZ to
ZonedTimestampType (TIMESTAMP_WITH_TIME_ZONE), but the Debezium deserializer
only has a converter for TIMESTAMP_WITH_LOCAL_TIME_ZONE. This mismatch causes
the deserializer to produce LocalZonedTimestampData while BinaryWriter.write()
casts to ZonedTimestampData, resulting in binary data corruption and
NumberFormatException when the Iceberg sink reads the field via
BinaryRecordData.getZonedTimestamp().

The existing test PostgresFullTypesITCase already expects LocalZonedTimestampData
for TIMESTAMPTZ (line 1211: DataTypes.TIMESTAMP_LTZ(0)), confirming the correct
type mapping is TIMESTAMP_WITH_LOCAL_TIME_ZONE.

Changes:
- PostgresTypeUtils: TIMESTAMPTZ -> TIMESTAMP_LTZ(scale) (was ZonedTimestampType)
- DebeziumEventDeserializationSchema: add convertToZonedTimestamp() for future
  TIMESTAMP_WITH_TIME_ZONE support
- Add PostgresTypeUtilsTimestamptzTest: validates TIMESTAMPTZ maps to
  TIMESTAMP_WITH_LOCAL_TIME_ZONE type root
- Add IcebergTypeUtilsTest: validates TIMESTAMP_LTZ type conversion and
  field getter creation for Iceberg sink
@avichaym avichaym force-pushed the fix/timestamptz-iceberg-sink branch from e8d1f25 to f48c4e4 Compare April 9, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant