seatunnel icon indicating copy to clipboard operation
seatunnel copied to clipboard

[Fix][Connector-Iceberg] Fix Time Zone Issue for Iceberg Timestamp Type

Open yzeng1618 opened this issue 6 months ago • 0 comments

https://github.com/apache/seatunnel/issues/9457

Purpose of this pull request

This PR fixes a timezone issue in the Iceberg connector when converting LocalDateTime to OffsetDateTime. Previously, LocalDateTime values were directly converted to UTC timezone without considering the system's local timezone, which could lead to incorrect timestamp values in Iceberg tables. This PR ensures that LocalDateTime values are properly interpreted in the system's timezone before being converted to UTC, preserving the correct instant in time.

Does this PR introduce any user-facing change?

Yes, this PR introduces a user-facing change in how timestamps are handled when writing data to Iceberg tables. Previously, LocalDateTime values were directly converted to UTC without considering the system timezone, which could result in incorrect timestamp values. After this change, LocalDateTime values will be correctly interpreted in the system's timezone before being converted to UTC, ensuring that the same instant in time is preserved. This change affects users who are writing timestamp data to Iceberg tables using the SeaTunnel Iceberg connector.

How was this patch tested?

This patch was tested by adding a comprehensive test class RowConverterTest.java that verifies various data type conversions, with special focus on timestamp handling. The test includes: A basic test that verifies conversion of all supported data types A specific test for timestamp with timezone conversion that: Creates a LocalDateTime instance Converts it using the RowConverter Verifies that the conversion correctly interprets the timestamp in the system timezone before converting to UTC Compares the result with a manually calculated expected value The test ensures that the same instant in time is preserved when converting from LocalDateTime to OffsetDateTime, regardless of the system's timezone settings.

Check list

  • [ ] If any new Jar binary package adding in your PR, please add License Notice according New License Guide
  • [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/seatunnel/tree/dev/docs
  • [ ] If you are contributing the connector code, please check that the following files are updated:
    1. Update plugin-mapping.properties and add new connector information in it
    2. Update the pom file of seatunnel-dist
    3. Add ci label in label-scope-conf
    4. Add e2e testcase in seatunnel-e2e
    5. Update connector plugin_config

yzeng1618 avatar Jun 18 '25 07:06 yzeng1618