FIX - Issue #408 - Column[ZonedDateTime] loses nanoseconds precision#409
Merged
cchantep merged 3 commits intoDec 1, 2021
Merged
FIX - Issue #408 - Column[ZonedDateTime] loses nanoseconds precision#409cchantep merged 3 commits into
cchantep merged 3 commits into
Conversation
|
At least one pull request committer is not linked to a user. See https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user#commits-are-not-linked-to-any-user |
Contributor
Author
|
Thanks for the review @cchantep. You're right no need to use |
markarasev
reviewed
Feb 9, 2023
| } | ||
|
|
||
| "be parsed from timestamp with nano precision" in { | ||
| val instantWithNanoPrecision = Instant.parse("2021-01-06T08:45:26.441477Z") |
There was a problem hiding this comment.
Is it me or the tested instant has a millisecond precision instead of nanosecond?
Contributor
Author
There was a problem hiding this comment.
The tested instant has 441477 microseconds. The issue was happening for all the presisions under millisecond. So the test is not wrong, just the naming.
gaeljw
pushed a commit
that referenced
this pull request
May 24, 2026
…714) * 🐛 fix: preserve nanosecond precision in Column[LocalDateTime] (#525) `columnToLocalDateTime` previously delegated through `temporalValueTo`, which extracts time as `Timestamp#getTime` (millisecond epoch) and reconstructs via `Instant.ofEpochMilli`, truncating sub-millisecond precision. Route through `instantValueTo` instead so `Timestamp#toInstant` preserves nanoseconds, mirroring the pattern of #326 (Instant) and #409 (ZonedDateTime). Regression test added to JavaTimeColumnSpec. Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv> * ♻️ refactor: address #714 review (inline helper, drop comments) Per @gaeljw's review: - Inline the instantToLocalDateTime helper as an `Instant` lambda passed directly to instantValueTo, matching columnToZonedDateTime. - Drop the routing rationale comments; the nano-precision test covers the behaviour. The `case localDateTime: LocalDateTime => Right(localDateTime)` short-circuit stays to avoid a ZoneId.systemDefault round-trip on non-UTC JVMs. Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv> --------- Signed-off-by: Onyeka Obi <softwareengineerasaservant@isurvivable.cv>
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.
Pull Request Checklist
Fixes
Fixes #408
Purpose
Fix the default instance of
Column[ZonedDateTime]in theJavaTimeColumntrait, so it doesn't lose the nanosecond precision during the SQL result reads.Background Context
When reading an SQL result,
TIMESTAMP[TZ]from database is mapped on thejava.sql.Timestamptype. This type extends fromjava.util.Datebut has a nanosecond precision. In current implementation the conversion is handle bytemporalValueTofunction:java.sql.Timestampis matched as ajava.util.Dateanddate.getTimeonly provides milliseconds.There was already a fix for the
Instanttype:My suggestion is to reuse this fix and to use
Instantas the intermediate type for date/time conversion instead ofLong.So that all conversion will have to provide a function
Instant => Twhen it wasLong => T.References
Column[Instant]fix #325 and PR #326