-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
feat: Always preserve sorted flag for .dt.date #18692
Conversation
DataType::Datetime(tu, Some(tz)) => { | ||
let mut out = { | ||
polars_ops::chunked_array::replace_time_zone( | ||
s.datetime().unwrap(), | ||
None, | ||
&StringChunked::from_iter(std::iter::once("raise")), | ||
NonExistent::Raise, | ||
)? | ||
.cast(&DataType::Datetime(*tu, None))? | ||
}; | ||
if tz != "UTC" { | ||
// DST transitions may not preserve sortedness. | ||
out.set_sorted_flag(IsSorted::Not); | ||
} | ||
Ok(out) | ||
}, | ||
DataType::Datetime(tu, Some(_)) => polars_ops::chunked_array::replace_time_zone( | ||
s.datetime().unwrap(), | ||
None, | ||
&StringChunked::from_iter(std::iter::once("raise")), | ||
NonExistent::Raise, | ||
)? | ||
.cast(&DataType::Datetime(*tu, None)), |
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.
polars_ops::chunked_array::replace_time_zone
already deals with unsetting the sortedness flag if necessary, so this can now be simplified
there's already tests which check sortedness for replacing the time zone:
- test_replace_time_zone_sortedness_series
- test_replace_time_zone_sortedness_expressions
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #18692 +/- ##
==========================================
+ Coverage 79.86% 79.87% +0.01%
==========================================
Files 1517 1517
Lines 205542 205532 -10
Branches 2892 2892
==========================================
+ Hits 164156 164173 +17
+ Misses 40838 40811 -27
Partials 548 548 ☔ View full report in Codecov by Sentry. |
pl.Series("ts", [1603584000000000, 1603587600000000]) | ||
pl.Series("ts", [1603584000000001, 1603587600000000]) |
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.
@orlp I think this is what you were asking for? like this, the example shows why the sorted flag shouldn't be preserved for 'Europe/London'
Can you rebase? |
No description provided.