Skip to content

Commit

Permalink
feat(polars): add any and all reductions
Browse files Browse the repository at this point in the history
  • Loading branch information
mesejo authored and gforsyth committed May 23, 2023
1 parent fc66380 commit 0bd3c01
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
20 changes: 20 additions & 0 deletions ibis/backends/polars/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,8 @@ def struct_column(op):
ops.Median: 'median',
ops.First: 'first',
ops.Last: 'last',
ops.All: 'all',
ops.Any: 'any',
}

for reduction in _reductions.keys():
Expand Down Expand Up @@ -1050,3 +1052,21 @@ def execute_union(op, **kwargs):
@translate.register(ops.Hash)
def execute_hash(op, **kwargs):
return translate(op.arg).hash()


@translate.register(ops.NotAll)
def execute_not_all(op, **kwargs):
arg = op.arg
if (op_where := op.where) is not None:
arg = ops.Where(op_where, arg, None)

return translate(arg).all().is_not()


@translate.register(ops.NotAny)
def execute_not_any(op, **kwargs):
arg = op.arg
if (op_where := op.where) is not None:
arg = ops.Where(op_where, arg, None)

return translate(arg).any().is_not()
12 changes: 6 additions & 6 deletions ibis/backends/tests/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def mean_and_std(v):
id='any',
marks=[
pytest.mark.notimpl(
["polars", "datafusion"],
["datafusion"],
raises=com.OperationNotDefinedError,
),
pytest.mark.broken(
Expand All @@ -295,7 +295,7 @@ def mean_and_std(v):
id='notany',
marks=[
pytest.mark.notimpl(
["polars", "datafusion"],
["datafusion"],
raises=com.OperationNotDefinedError,
),
pytest.mark.broken(
Expand All @@ -316,7 +316,7 @@ def mean_and_std(v):
id='any_negate',
marks=[
pytest.mark.notimpl(
["polars", "datafusion"],
["datafusion"],
raises=com.OperationNotDefinedError,
),
pytest.mark.broken(
Expand All @@ -337,7 +337,7 @@ def mean_and_std(v):
id='all',
marks=[
pytest.mark.notimpl(
["polars", "datafusion"],
["datafusion"],
raises=com.OperationNotDefinedError,
),
pytest.mark.broken(
Expand All @@ -353,7 +353,7 @@ def mean_and_std(v):
id='notall',
marks=[
pytest.mark.notimpl(
["polars", "datafusion"],
["datafusion"],
raises=com.OperationNotDefinedError,
),
pytest.mark.broken(
Expand All @@ -374,7 +374,7 @@ def mean_and_std(v):
id='all_negate',
marks=[
pytest.mark.notimpl(
["polars", "datafusion"],
["datafusion"],
raises=com.OperationNotDefinedError,
),
pytest.mark.broken(
Expand Down

0 comments on commit 0bd3c01

Please sign in to comment.