Repository navigation
[client-v2] Fix reading negative Time64 values with fractional seconds - #3456
Open
shafiktanbir wants to merge 1 commit into
Open
shafiktanbir wants to merge 1 commit into
shafiktanbir wants to merge 1 commit into
Conversation
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.
Summary
DataTypeUtils.localTimeFromTime64Integerpreviously tookMath.abs(value % factor)and truncatedvalue / factortoward zero. For negativeTime64values with a non-zero fractional part,LocalDateTime.ofEpochSecond(seconds, nanoOfSecond, UTC)added the positive nanosecond offset to the truncated seconds, shifting the decoded value forward (for example,-01:02:03.456became-01:02:02.544).This change applies floor division when
value % factor < 0, matchingDataTypeUtils.instantFromTime64Integer. It also removes the resolvedReaderKnownIssuesentry and updates the negativeTime64expectations inDataTypeTestsandJdbcDataTypeTests.Compatibility impact: No public API signatures or return types change. Callers reading negative
Time64values with fractional seconds viagetDuration,getTemporalAmount,getLocalDateTime,getInstant, or JDBCgetObject(..., LocalDateTime.class)now receive the exact negative value instead of a value shifted by up to two seconds. Zero and positiveTime64values, and negative values with a zero fraction, are unchanged.Local verification:
TZ=UTC mvn -pl client-v2 -Dgroups=unit -DargLine="-Duser.timezone=UTC" test(496tests run,0failures)mvn -Dj8 -pl client-v2,jdbc-v2 -am -DskipTests test-compile(Java 8 compile check passed across all 6 reactor modules)Closes #3419
Checklist
Note
Medium Risk
Behavior change for negative Time64 with sub-second parts affects client and JDBC temporal accessors; positive/zero paths are intended unchanged but callers may see different decoded values where the bug was present.
Overview
Fixes
DataTypeUtils.localTimeFromTime64Integerso negativeTime64values with a fractional part decode correctly. The old path usedMath.abson the remainder and truncated seconds toward zero, which could shift decoded times by up to a couple of seconds (for example-01:02:03.456landing around-01:02:02.544).localTimeFromTime64Integernow uses the same floor-style split asinstantFromTime64Integer: when the remainder is negative, it normalizes nanoseconds and borrows one second.Downstream readers (
getDuration,getLocalDateTime,getInstant, JDBCLocalDateTime) pick up the fix without API changes. Tests and integration expectations for negativeTime64are updated, the resolvedReaderKnownIssuesentry is removed, and a changelog note is added for #3419.Reviewed by Cursor Bugbot for commit ffcb44e. Bugbot is set up for automated code reviews on this repo. Configure here.