Skip to content

Commit

Permalink
fix(polars): project first when creating computed grouping keys
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored and kszucs committed Dec 6, 2023
1 parent 6817981 commit 7f9fdd4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ibis/backends/polars/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ def aggregation(op, **kw):
)
)

# project first to handle computed group by columns
lf = lf.with_columns([translate(arg, **kw) for arg in op.by])

if op.by:
group_by = [translate(arg, **kw) for arg in op.by]
lf = lf.group_by(group_by).agg
lf = lf.group_by([pl.col(by.name) for by in op.by]).agg
else:
lf = lf.select

Expand Down

0 comments on commit 7f9fdd4

Please sign in to comment.