-
-
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
fix: Fix Expr.over
with order_by
did not take effect if group keys were sorted
#18947
Conversation
.over([col("cars")]) | ||
.explode() |
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.
This query internally created a DataFrame of height 5 containing a list[_]
type column of length 2 (the imploded aggregation result), which it then exploded 🤯 out to the correct height, where the correctness of the result was guaranteed because the DataFrame was sorted beforehand 😂
@@ -334,13 +333,8 @@ impl WindowExpr { | |||
// no explicit aggregations, map over the groups | |||
//`(col("x").sum() * col("y")).over("groups")` | |||
(WindowMapping::GroupsToRows, AggState::AggregatedList(_)) => { | |||
if sorted_keys { | |||
if let GroupsProxy::Idx(g) = gb.get_groups() { | |||
debug_assert!(g.is_sorted_flag()) |
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.
GroupsProxy::Idx
must be explicitly mapped back to the row positions regardless of whether it was sorted
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #18947 +/- ##
==========================================
- Coverage 79.88% 79.87% -0.02%
==========================================
Files 1522 1522
Lines 206958 206954 -4
Branches 2906 2906
==========================================
- Hits 165322 165297 -25
- Misses 41088 41109 +21
Partials 548 548 ☔ View full report in Codecov by Sentry. |
Fixes #18943