Skip to content

fix: include location in Session-based temporary storage manager DDL queries #1780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 30, 2025
Prev Previous commit
Next Next commit
validate location of the destination table
  • Loading branch information
tswast committed May 30, 2025
commit 15fa7289e13ce63ae04382c126ac167254d33549
29 changes: 24 additions & 5 deletions tests/system/large/test_location.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import typing

from google.cloud import bigquery
import pandas
import pandas.testing
import pytest
Expand All @@ -40,7 +39,15 @@ def _assert_bq_execution_location(
if expected_location is None:
expected_location = session._location

assert typing.cast(bigquery.QueryJob, df.query_job).location == expected_location
query_job = df.query_job
assert query_job is not None
assert query_job.location == expected_location
destination = query_job.destination
assert destination is not None
destination_dataset = session.bqclient.get_dataset(
f"{destination.project}.{destination.dataset_id}"
)
assert destination_dataset.location == expected_location

# Ensure operation involving BQ client suceeds
result = (
Expand All @@ -51,15 +58,27 @@ def _assert_bq_execution_location(
.head()
)

assert (
typing.cast(bigquery.QueryJob, result.query_job).location == expected_location
# Use allow_large_results = True to force a job to be created.
result_pd = result.to_pandas(allow_large_results=True)

query_job = df.query_job
assert query_job is not None
assert query_job.location == expected_location
destination = query_job.destination
assert destination is not None
destination_dataset = session.bqclient.get_dataset(
f"{destination.project}.{destination.dataset_id}"
)
assert destination_dataset.location == expected_location

expected_result = pandas.DataFrame(
{"number": [444, 222]}, index=pandas.Index(["aaa", "bbb"], name="name")
)
pandas.testing.assert_frame_equal(
expected_result, result.to_pandas(), check_dtype=False, check_index_type=False
expected_result,
result_pd,
check_dtype=False,
check_index_type=False,
)


Expand Down