Skip to content

Commit c15cb8a

Browse files
authored
fix: resolve location reset issue in bigquery options (#1914)
* fix: resolve location reset issue in bigquery options * fix * fix * fix the test
1 parent 8baa912 commit c15cb8a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

bigframes/_config/bigquery_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def location(self) -> Optional[str]:
171171

172172
@location.setter
173173
def location(self, value: Optional[str]):
174-
if self._session_started and self._location != value:
174+
if self._session_started and self._location != _get_validated_location(value):
175175
raise ValueError(SESSION_STARTED_MESSAGE.format(attribute="location"))
176176
self._location = _get_validated_location(value)
177177

tests/unit/_config/test_bigquery_options.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ def test_setter_raises_if_session_started(attribute, original_value, new_value):
5858
assert getattr(options, attribute) is not new_value
5959

6060

61+
def test_location_set_us_twice():
62+
"""This test ensures the fix for b/423220936 is working as expected."""
63+
options = bigquery_options.BigQueryOptions()
64+
setattr(options, "location", "us")
65+
assert getattr(options, "location") == "US"
66+
67+
options._session_started = True
68+
69+
setattr(options, "location", "us")
70+
assert getattr(options, "location") == "US"
71+
72+
6173
@pytest.mark.parametrize(
6274
[
6375
"attribute",

0 commit comments

Comments
 (0)