Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(polars): fix groupconcat cardinality with sort_by
Browse files Browse the repository at this point in the history
cpcloud committed Aug 2, 2024

Verified

This commit was signed with the committer’s verified signature.
BerndKue Bernd
1 parent 97d7272 commit 141a263
Showing 2 changed files with 3 additions and 3 deletions.
5 changes: 3 additions & 2 deletions ibis/backends/polars/compiler.py
Original file line number Diff line number Diff line change
@@ -1414,10 +1414,11 @@ def execute_group_concat(op, **kw):
if (where := op.where) is not None:
predicate &= translate(where, **kw)

arg = arg.filter(predicate)

if order_by := op.order_by:
keys = [translate(k.expr, **kw).filter(predicate) for k in order_by]
descending = [k.descending for k in order_by]
arg = arg.sort_by(keys, descending=descending)

no_nulls = arg.filter(predicate)
return pl.when(no_nulls.count() > 0).then(no_nulls.str.join(sep)).otherwise(None)
return pl.when(arg.count() > 0).then(arg.str.join(sep)).otherwise(None)
1 change: 0 additions & 1 deletion ibis/backends/tests/test_aggregation.py
Original file line number Diff line number Diff line change
@@ -1328,7 +1328,6 @@ def test_group_concat(
],
raises=com.UnsupportedOperationError,
)
@pytest.mark.notimpl(["polars"], raises=com.OperationNotDefinedError)
@pytest.mark.parametrize("filtered", [False, True])
def test_group_concat_ordered(alltypes, df, filtered):
ibis_cond = (_.id % 13 == 0) if filtered else None

0 comments on commit 141a263

Please sign in to comment.