From eb5f6740b37739d4508872715bc8d403666d288f Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 19 Sep 2024 06:27:46 -0400 Subject: [PATCH] fix(polars): use double explode -> implode hack to flatten --- ibis/backends/polars/compiler.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ibis/backends/polars/compiler.py b/ibis/backends/polars/compiler.py index 7bc9c9f147152..20f5ff15749ba 100644 --- a/ibis/backends/polars/compiler.py +++ b/ibis/backends/polars/compiler.py @@ -1021,7 +1021,11 @@ def array_flatten(op, **kw): .then(None) .when(result.list.len() == 0) .then([]) - .otherwise(result.flatten()) + # polars doesn't have an efficient API (yet?) for removing one level of + # nesting from an array so we use elementwise evaluation + # + # https://github.com/ibis-project/ibis/issues/10135 + .otherwise(result.list.eval(pl.element().flatten())) )