[hive] Fix timestamp inspector for pre-epoch timestamps in Hive 3.1#8645
Open
thswlsqls wants to merge 1 commit into
Open
[hive] Fix timestamp inspector for pre-epoch timestamps in Hive 3.1#8645thswlsqls wants to merge 1 commit into
thswlsqls wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
fix #8644
PaimonTimestampObjectInspector.getPrimitiveJavaObject()(Hive 3.1) computed nano-of-second withmillis % 1000, negative for pre-1970 timestamps that Paimon stores as a negativemillisecond.nanosmade Hive 3.1Timestamp.ofEpochMilli(long,int)throwDateTimeExceptionviaLocalDateTime.withNano, so a validSELECTof a pre-epoch fractional TIMESTAMP crashed.Math.floorMod(millis, 1000L)to keep sub-second nanos in[0, 999_999_999]; the positive path is unchanged (floorMod == %for non-negative millis).paimon-hive-connector-common, which delegates tojava.sql.Timestampand already handles negative millis.Tests
PaimonTimestampObjectInspectorTestcovering the pre-epoch regression, the unchanged post-1970 path, and null; expected HiveTimestampvalues are derived from the sourceLocalDateTimevia 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*ITCasetests need a HiveServer and are covered by CI.