Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support larger dates in TypeDate marshalling #1692

Merged
merged 4 commits into from
Jun 5, 2023

Conversation

olib963
Copy link
Contributor

@olib963 olib963 commented Apr 27, 2023

We are using nanosecond precision when reading a TypeDate into a time.Time value, this limits the dates we can accurately read and write from cassandra to [1677-09-22, 2262-04-11] since outside of this range we end up with integer overflow. Dates outside of this range encode correctly and are persisted in Cassandra, but are then read as an incorrect value.

The new supported date range is [-5877641-06-23, 5881580-07-11] given that we are decoding the epoch day as a 32 bit int (-2147483648 = minimum int = -5877641-06-23). I think it's possible to expand the range if ever needed by decoding a 64 bit int and using time.Unix(seconds, 0), but I didn't think it was worth looking into that change.

Please let me know if I missed anything from the testing.

@olib963 olib963 marked this pull request as ready for review June 5, 2023 09:57
Copy link
Contributor

@martin-sucha martin-sucha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you for the pull request!

@martin-sucha martin-sucha merged commit 72bc15e into apache:master Jun 5, 2023
@olib963 olib963 deleted the support-larger-dates branch June 5, 2023 14:30
@olib963 olib963 restored the support-larger-dates branch June 6, 2023 08:59
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.

2 participants