Skip to content

Commit

Permalink
fix(bigquery): get literals working again (#8577)
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud authored Mar 12, 2024
1 parent f1d0f65 commit 6369734
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
12 changes: 11 additions & 1 deletion ibis/backends/bigquery/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ def _load_data(self, **_: Any) -> None:
os.environ.get(PROJECT_ID_ENV_VAR, default_project_id) or DEFAULT_PROJECT_ID
)

client = bq.Client(project=project_id, credentials=credentials)
client = bq.Client(
project=project_id,
credentials=credentials,
default_query_job_config=bq.QueryJobConfig(use_query_cache=False),
)
assert client.default_query_job_config.use_query_cache is False

try:
client.query("SELECT 1")
Expand Down Expand Up @@ -280,6 +285,11 @@ def connect(*, tmpdir, worker_id, **kw) -> Backend:
con = ibis.bigquery.connect(
project_id=project_id, dataset_id=DATASET_ID, credentials=credentials, **kw
)
# disable the query cache to avoid invalid results
#
# it's rare, but it happens
# https://github.com/googleapis/python-bigquery/issues/1845
con.client.default_query_job_config.use_query_cache = False
expr = ibis.literal(1)
try:
con.execute(expr)
Expand Down
1 change: 1 addition & 0 deletions ibis/backends/bigquery/tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def con(credentials, project_id, dataset_id):
con = ibis.bigquery.connect(
project_id=project_id, dataset_id=dataset_id, credentials=credentials
)
con.client.default_query_job_config.use_query_cache = False
try:
con.sql("SELECT 1")
except gexc.Forbidden:
Expand Down
3 changes: 3 additions & 0 deletions ibis/backends/bigquery/tests/system/udf/test_udf_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ def test_builtin_scalar(con, value, expected):
@udf.scalar.builtin
def bit_count(x: bytes) -> int: ...

assert con.client.default_query_job_config.use_query_cache is False

expr = bit_count(value)

result = con.execute(expr)
assert result == expected

Expand Down
4 changes: 3 additions & 1 deletion ibis/backends/pyspark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ def drop_database(self, name: str, force: bool = False) -> Any:
database does not exist
"""
sql = sge.Drop(kind="DATABASE", exist=force, this=sg.to_identifier(name))
sql = sge.Drop(
kind="DATABASE", exist=force, this=sg.to_identifier(name), cascade=force
)
with self._safe_raw_sql(sql):
pass

Expand Down
8 changes: 3 additions & 5 deletions ibis/backends/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1343,12 +1343,10 @@ def test_persist_expression_release(con, alltypes):


@contextlib.contextmanager
def gen_test_name(con: BaseBackend) -> str:
def gen_test_name(con: BaseBackend):
name = gen_name("test_table")
try:
yield name
finally:
con.drop_table(name, force=True)
yield name
con.drop_table(name, force=True)


@mark.notimpl(
Expand Down

0 comments on commit 6369734

Please sign in to comment.