Skip to content

[hive] Fix timestamp inspector for pre-epoch timestamps in Hive 3.1#8645

Open
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/hive31-timestamp-inspector-pre-epoch
Open

[hive] Fix timestamp inspector for pre-epoch timestamps in Hive 3.1#8645
thswlsqls wants to merge 1 commit into
apache:masterfrom
thswlsqls:fix/hive31-timestamp-inspector-pre-epoch

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Purpose

fix #8644

  • PaimonTimestampObjectInspector.getPrimitiveJavaObject() (Hive 3.1) computed nano-of-second with millis % 1000, negative for pre-1970 timestamps that Paimon stores as a negative millisecond.
  • The negative nanos made Hive 3.1 Timestamp.ofEpochMilli(long,int) throw DateTimeException via LocalDateTime.withNano, so a valid SELECT of a pre-epoch fractional TIMESTAMP crashed.
  • Use Math.floorMod(millis, 1000L) to keep sub-second nanos in [0, 999_999_999]; the positive path is unchanged (floorMod == % for non-negative millis).
  • Matches paimon-hive-connector-common, which delegates to java.sql.Timestamp and already handles negative millis.

Tests

  • Added PaimonTimestampObjectInspectorTest covering the pre-epoch regression, the unchanged post-1970 path, and null; expected Hive Timestamp values are derived from the source LocalDateTime via an independent epoch-second path.
  • mvn -pl paimon-hive/paimon-hive-connector-3.1 clean install (JDK 11) — 3 new unit tests pass, checkstyle/spotless/rat clean. The module *ITCase tests need a HiveServer and are covered by CI.

PaimonTimestampObjectInspector.getPrimitiveJavaObject computed the
nano-of-second with `millis % 1000`, which is negative for pre-1970
timestamps that Paimon stores as a negative millisecond. The negative
value made Hive 3.1 Timestamp.ofEpochMilli throw a DateTimeException via
LocalDateTime.withNano, so reading a pre-epoch fractional TIMESTAMP
failed. Use Math.floorMod to keep the sub-second nanos in range; the
positive path is unchanged.

Generated-by: Claude Code
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.

[Bug] Hive 3.1 timestamp inspector fails on pre-epoch fractional timestamps

1 participant