8000 fix: resolve location reset issue in bigquery options by jialuoo · Pull Request #1914 · googleapis/python-bigquery-dataframes · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by ex 8000 tension

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
< 1638 ghcc-consent id="ghcc" class="position-fixed bottom-0 left-0" style="z-index: 999999" data-locale="en" data-initial-cookie-consent-allowed="" data-cookie-consent-required="false" >
0