-
Notifications
You must be signed in to change notification settings - Fork 8
feat: Add time_zone
to Datetime
result
s
#33
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
base: main
Are you sure you want to change the base?
feat: Add time_zone
to Datetime
result
s
#33
Conversation
allows setting a time zone for datetimes and checking if the values in the column matches it
( | ||
dy.Date(), | ||
[dt.date(2020, 1, 1), dt.date(2021, 1, 15), dt.date(2022, 12, 1)], | ||
{}, | ||
), | ||
( | ||
dy.Date(resolution="1mo"), | ||
[dt.date(2020, 1, 1), dt.date(2021, 1, 15), dt.date(2022, 12, 1)], | ||
{"resolution": [True, False, True]}, | ||
), | ||
( | ||
dy.Time(), | ||
[dt.time(12, 0), dt.time(13, 15), dt.time(14, 0, 5)], | ||
{}, | ||
), | ||
( | ||
dy.Time(resolution="1h"), | ||
[dt.time(12, 0), dt.time(13, 15), dt.time(14, 0, 5)], | ||
{"resolution": [True, False, False]}, | ||
), | ||
( | ||
dy.Datetime(), | ||
[ | ||
dt.datetime(2020, 4, 5), | ||
dt.datetime(2021, 1, 1, 12), | ||
dt.datetime(2022, 7, 10, 0, 0, 1), | ||
], | ||
{}, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added these since I wanted to double-check the negative case when nothing is specified, but I'm happy to remove them if you believe these are too verbose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it a little confusing to have these cases here. The test is named test_validate_resolution
after all. I'd propose to remove
time_zone
to Datetime
result
stime_zone
to Datetime
result
s
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #33 +/- ##
===========================================
- Coverage 100.00% 99.89% -0.11%
===========================================
Files 38 38
Lines 1845 1852 +7
===========================================
+ Hits 1845 1850 +5
- Misses 0 2 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the nice PR @dfrankland! Could you add a test in test_sql_schema.py
for the oracle part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the initiative @dfrankland, I think this is a very useful addition! :)
time_zone
to Datetime
result
stime_zone
to Datetime
result
s
Let me know if you'd like for me to rebase these changes |
8de8c8f
to
30e3538
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, nice, I think we're almost there! :)
return sa_mssql.DATETIME2(6) | ||
return sa_mssql.DATETIME2(6, timezone=timezone_enabled) | ||
case "postgresql": | ||
return sa_postgresql.TIMESTAMP(timezone=timezone_enabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this extra condition for postgres or does sa.DateTime(timezone=timezone_enabled)
map to TIMESTAMPTZ
anyways? We're currently not maintaining 100% coverage (which we should) because we're not using the default case.
( | ||
dy.Date(), | ||
[dt.date(2020, 1, 1), dt.date(2021, 1, 15), dt.date(2022, 12, 1)], | ||
{}, | ||
), | ||
( | ||
dy.Date(resolution="1mo"), | ||
[dt.date(2020, 1, 1), dt.date(2021, 1, 15), dt.date(2022, 12, 1)], | ||
{"resolution": [True, False, True]}, | ||
), | ||
( | ||
dy.Time(), | ||
[dt.time(12, 0), dt.time(13, 15), dt.time(14, 0, 5)], | ||
{}, | ||
), | ||
( | ||
dy.Time(resolution="1h"), | ||
[dt.time(12, 0), dt.time(13, 15), dt.time(14, 0, 5)], | ||
{"resolution": [True, False, False]}, | ||
), | ||
( | ||
dy.Datetime(), | ||
[ | ||
dt.datetime(2020, 4, 5), | ||
dt.datetime(2021, 1, 1, 12), | ||
dt.datetime(2022, 7, 10, 0, 0, 1), | ||
], | ||
{}, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it a little confusing to have these cases here. The test is named test_validate_resolution
after all. I'd propose to remove
), | ||
], | ||
) | ||
def test_dtype_validation( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]
def test_dtype_validation( | |
def test_dtype_time_zone_validation( |
Motivation
Closes #32
Changes
allows setting a time zone for datetimes and checking if the values in the column matches it
Pertinent polars docs:
https://docs.pola.rs/user-guide/transformations/time-series/timezones/