diff --git a/bigframes/_config/bigquery_options.py b/bigframes/_config/bigquery_options.py index 09ffee95d4..648b69dea7 100644 --- a/bigframes/_config/bigquery_options.py +++ b/bigframes/_config/bigquery_options.py @@ -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) diff --git a/tests/unit/_config/test_bigquery_options.py b/tests/unit/_config/test_bigquery_options.py index 686499aa75..3c80f00a37 100644 --- a/tests/unit/_config/test_bigquery_options.py +++ b/tests/unit/_config/test_bigquery_options.py @@ -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",