From 2cc9d0ef3cd4106f1cc823f3c36db22963ec13f4 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 19 Oct 2023 09:02:49 -0400 Subject: [PATCH] fix(bigquery): apply unnest transformation in other methods that execute SQL --- ibis/backends/bigquery/__init__.py | 8 ++++---- ibis/backends/tests/test_array.py | 3 +++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ibis/backends/bigquery/__init__.py b/ibis/backends/bigquery/__init__.py index 0675fb3bf498..2114647c397e 100644 --- a/ibis/backends/bigquery/__init__.py +++ b/ibis/backends/bigquery/__init__.py @@ -473,8 +473,8 @@ def to_pyarrow( **kwargs: Any, ) -> pa.Table: self._import_pyarrow() - query_ast = self.compiler.to_ast_ensure_limit(expr, limit, params=params) - sql = query_ast.compile() + sql = self.compile(expr, limit=limit, params=params, **kwargs) + self._log(sql) cursor = self.raw_sql(sql, params=params, **kwargs) table = self._cursor_to_arrow(cursor) return expr.__pyarrow_result__(table) @@ -492,8 +492,8 @@ def to_pyarrow_batches( schema = expr.as_table().schema() - query_ast = self.compiler.to_ast_ensure_limit(expr, limit, params=params) - sql = query_ast.compile() + sql = self.compile(expr, limit=limit, params=params, **kwargs) + self._log(sql) cursor = self.raw_sql(sql, params=params, **kwargs) batch_iter = self._cursor_to_arrow( cursor, diff --git a/ibis/backends/tests/test_array.py b/ibis/backends/tests/test_array.py index f60dc473ed44..67ca7058feee 100644 --- a/ibis/backends/tests/test_array.py +++ b/ibis/backends/tests/test_array.py @@ -373,6 +373,9 @@ def test_unnest_complex(backend): result = expr.execute() tm.assert_frame_equal(result, expected) + # test that unnest works with to_pyarrow + assert len(expr.to_pyarrow()) == len(result) + @builtin_array @pytest.mark.never(