Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(polars): add workaround to compile Array<Array> correctly #9484

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ibis/backends/polars/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,13 @@ def array_concat(op, **kw):
@translate.register(ops.Array)
def array_column(op, **kw):
cols = [translate(col, **kw) for col in op.exprs]
# Workaround for https://github.com/pola-rs/polars/issues/17294
# pl.concat_list(Iterable[T]) results in pl.List[T], EXCEPT when T is a
# pl.List, in which case pl.concat_list(Iterable[pl.List[T]]) results in pl.List[T].
# If polars ever supports a more consistent array constructor,
# we should switch to that.
if op.dtype.value_type.is_array():
cols = [c.implode() for c in cols]
return pl.concat_list(cols)


Expand Down
9 changes: 1 addition & 8 deletions ibis/backends/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -1352,14 +1352,7 @@ def test_unnest_range(con):
[[1], ibis.literal([2])],
[[1], [2]],
id="array",
marks=[
pytest.mark.notyet(["bigquery"], raises=GoogleBadRequest),
pytest.mark.broken(
["polars"],
reason="expression input not supported with nested arrays",
raises=TypeError,
),
],
marks=[pytest.mark.notyet(["bigquery"], raises=GoogleBadRequest)],
),
],
)
Expand Down