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

Introduce Datetime type for ranges outside datetime.[MIN|MAX]YEAR #1200

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sylwiaszunejko
Copy link

@sylwiaszunejko sylwiaszunejko commented Mar 25, 2024

In Python datetime.datetime type year has to be in range [MINYEAR, MAXYEAR]. This range is not the same as possible timestamps in scylla. Previously if timestamp was outside this range it made driver raise an Exception. It was not correct behavior. There was a work around implemented in cqlsh.

This PR introduces a Datetime type to accommodate ranges outside datetime.[MIN|MAX]YEAR. For Datetimes that cannot be represented as a datetime.datetime (because datetime.MINYEAR, datetime.MAXYEAR), this type falls back to printing milliseconds_from_epoch offset.

Something similar was introduced before for datetime.date type - scylladb@4f3c77c.

This is for sure a breaking change, because of change of the return type. The question is if it is worth to break compatibility for fixing this bug. As far as I know it was not reported by any users, in scylladb we encounter it on two occasions in tests.

This PR is based on scylladb#310 - in scylladb we are considering different approaches to this problem and it would be helpful to know your opinion on that.

This is the original issue: https://datastax-oss.atlassian.net/browse/PYTHON-441. I've left a comment there to reopen the discussion.

In Python `datetime.datetime` type year has to be in range
[MINYEAR, MAXYEAR]. This range is not the same as possible timestamps
in scylla. Previously if timestamp was outside this range it made
driver raise an Exception. It was not correct behavior. There was a
work around implemented in cqlsh.

This commit introduces a `Datetime` type to accommodate ranges outside
datetime.[MIN|MAX]YEAR. For Datetimes that cannot be represented as
a datetime.datetime (because datetime.MINYEAR, datetime.MAXYEAR),
this type falls back to printing milliseconds_from_epoch offset.
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.

1 participant