Repository navigation
fix: preserve microsecond precision for Avro timestamp-micros in JDBC… - #119
Merged
orfeon merged 1 commit intoAug 5, 2026
Merged
Conversation
… statements ToStatementConverter converted timestamp-micros with Instant.ofEpochMilli(micros / 1000). The integer division discarded the sub-millisecond digits, so distinct timestamps collapsed onto the same value once bound to a PreparedStatement: 2026-07-30T12:48:16.123456Z -> 2026-07-30T12:48:16.123Z 2026-07-30T12:48:16.123789Z -> 2026-07-30T12:48:16.123Z java.sql.Timestamp carries nanosecond precision, so build the Instant from microseconds directly with Instant.EPOCH.plus(micros, MICROS). That also fixes pre-1970 values, where integer division truncated toward zero and rounded the wrong way. Other call sites that divide micros by 1000 target org.joda.time.Instant, which is millisecond-resolution by design, so they are left unchanged. Fixes mercari#118
orfeon
approved these changes
Aug 5, 2026
orfeon
left a comment
Member
There was a problem hiding this comment.
Thank you for your contribution!
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.
… statements
ToStatementConverter converted timestamp-micros with Instant.ofEpochMilli(micros / 1000). The integer division discarded the sub-millisecond digits, so distinct timestamps collapsed onto the same value once bound to a PreparedStatement:
2026-07-30T12:48:16.123456Z -> 2026-07-30T12:48:16.123Z
2026-07-30T12:48:16.123789Z -> 2026-07-30T12:48:16.123Z
java.sql.Timestamp carries nanosecond precision, so build the Instant from microseconds directly with Instant.EPOCH.plus(micros, MICROS). That also fixes pre-1970 values, where integer division truncated toward zero and rounded the wrong way.
Other call sites that divide micros by 1000 target org.joda.time.Instant, which is millisecond-resolution by design, so they are left unchanged.
Fixes #118
Please read the CLA carefully before submitting your contribution to Mercari.
Under any circumstances, by submitting your contribution, you are deemed to accept and agree to be bound by the terms and conditions of the CLA.
https://www.mercari.com/cla/