Skip to content

Commit

Permalink
feat(bigquery): enable subqueries in select statements
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Feb 7, 2023
1 parent d4f0275 commit ef4dc86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ibis/backends/base/sql/compiler/query_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def format_select_set(self):
formatted = []
for node in self.select_set:
if isinstance(node, ops.Value):
expr_str = self._translate(node, named=True)
expr_str = self._translate(node, named=True, permit_subquery=True)
elif isinstance(node, ops.TableNode):
alias = context.get_ref(node)
expr_str = f'{alias}.*' if alias else '*'
Expand Down
9 changes: 5 additions & 4 deletions ibis/backends/tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,22 +842,23 @@ def test_typeof(backend, con):


@pytest.mark.broken(["polars"], reason="incorrect answer")
@pytest.mark.notimpl(["datafusion", "bigquery", "impala", "pyspark"])
@pytest.mark.notyet(["impala"], reason="can't find table in subquery")
@pytest.mark.notimpl(["datafusion", "pyspark"])
@pytest.mark.notyet(["dask", "mssql"], reason="not supported by the backend")
def test_isin_uncorrelated(
backend, batting, awards_players, batting_df, awards_players_df
):
expr = batting.select(
"playerID",
"yearID",
x=batting.yearID.isin(awards_players.yearID),
has_year_id=batting.yearID.isin(awards_players.yearID),
).order_by(["playerID", "yearID"])
result = expr.execute().x
result = expr.execute().has_year_id
expected = (
batting_df.sort_values(["playerID", "yearID"])
.reset_index(drop=True)
.yearID.isin(awards_players_df.yearID)
.rename("x")
.rename("has_year_id")
)
backend.assert_series_equal(result, expected)

Expand Down

0 comments on commit ef4dc86

Please sign in to comment.