Skip to content

Commit

Permalink
fix(bigquery): apply unnest transformation in other methods that exec…
Browse files Browse the repository at this point in the history
…ute SQL
  • Loading branch information
cpcloud authored and jcrist committed Oct 19, 2023
1 parent 940ed21 commit 2cc9d0e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ibis/backends/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions ibis/backends/tests/test_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 2cc9d0e

Please sign in to comment.