Skip to content

Commit

Permalink
c
Browse files Browse the repository at this point in the history
  • Loading branch information
nameexhaustion committed Sep 27, 2024
1 parent 140bf15 commit ccc9580
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/polars-core/src/frame/group_by/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl GroupsProxy {
}
}

pub fn is_sorted_flag(&self) -> bool {
pub(crate) fn is_sorted_flag(&self) -> bool {
match self {
GroupsProxy::Idx(groups) => groups.is_sorted_flag(),
GroupsProxy::Slice { .. } => true,
Expand Down
12 changes: 5 additions & 7 deletions crates/polars-expr/src/expressions/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,14 @@ impl WindowExpr {
(WindowMapping::Join, AggState::AggregatedList(_)) => Ok(MapStrategy::Join),
// no explicit aggregations, map over the groups
//`(col("x").sum() * col("y")).over("groups")`
(WindowMapping::GroupsToRows, AggState::AggregatedList(_))
if gb.get_groups().is_sorted_flag() =>
{
if let GroupsProxy::Idx(_) = gb.get_groups() {
Ok(MapStrategy::Map)
} else {
(WindowMapping::GroupsToRows, AggState::AggregatedList(_)) => {
if let GroupsProxy::Slice { .. } = gb.get_groups() {
// Result can be directly exploded if the input was sorted.
Ok(MapStrategy::Explode)
} else {
Ok(MapStrategy::Map)
}
},
(WindowMapping::GroupsToRows, AggState::AggregatedList(_)) => Ok(MapStrategy::Map),
// no aggregations, just return column
// or an aggregation that has been flattened
// we have to check which one
Expand Down

0 comments on commit ccc9580

Please sign in to comment.