Skip to content

Commit

Permalink
feat(polars): add ArrayUnion operation (#10330)
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek authored Oct 18, 2024
1 parent 9134ef5 commit 4d5e847
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 7 additions & 0 deletions ibis/backends/polars/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,3 +1532,10 @@ def visit_ArrayRemove(op, **kw):
arg = translate(op.arg, **kw)
value = _literal_value(op.other)
return arg.list.set_difference(pl.lit([value]))


@translate.register(ops.ArrayUnion)
def visit_ArrayUnion(op, **kw):
left = translate(op.left, **kw)
right = translate(op.right, **kw)
return left.list.set_union(right)
5 changes: 2 additions & 3 deletions ibis/backends/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,6 @@ def test_array_sort(con, data):


@builtin_array
@pytest.mark.notimpl(["polars"], raises=com.OperationNotDefinedError)
@pytest.mark.parametrize(
("a", "b", "expected_array"),
[
Expand All @@ -853,9 +852,9 @@ def test_array_sort(con, data):
reason="BigQuery doesn't support arrays with null elements",
),
pytest.mark.notyet(
["datafusion"],
["datafusion", "polars"],
raises=AssertionError,
reason="DataFusion transforms null elements to NAN",
reason="Null elements are transformed to NaN",
),
pytest.mark.notyet(
["pyspark"],
Expand Down

0 comments on commit 4d5e847

Please sign in to comment.