Skip to content

fix: resolve location reset issue in bigquery options #1914

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 5 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bigframes/_config/bigquery_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def location(self) -> Optional[str]:

@location.setter
def location(self, value: Optional[str]):
if self._session_started and self._location != value:
if self._session_started and self._location != _get_validated_location(value):
raise ValueError(SESSION_STARTED_MESSAGE.format(attribute="location"))
self._location = _get_validated_location(value)

Expand Down
12 changes: 12 additions & 0 deletions tests/unit/_config/test_bigquery_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ def test_setter_raises_if_session_started(attribute, original_value, new_value):
assert getattr(options, attribute) is not new_value


def test_location_set_us_twice():
"""This test ensures the fix for b/423220936 is working as expected."""
options = bigquery_options.BigQueryOptions()
setattr(options, "location", "us")
assert getattr(options, "location") == "US"

options._session_started = True

setattr(options, "location", "us")
assert getattr(options, "location") == "US"


@pytest.mark.parametrize(
[
"attribute",
Expand Down