Skip to content
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

fix: allow storage_billing_model to be explicitly set to None to use project default value #1665

Merged
merged 2 commits into from
Oct 2, 2023
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
17 changes: 8 additions & 9 deletions google/cloud/bigquery/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,10 @@ def storage_billing_model(self):
"""Union[str, None]: StorageBillingModel of the dataset as set by the user
(defaults to :data:`None`).

Set the value to one of ``'LOGICAL'`` or ``'PHYSICAL'``. This change
takes 24 hours to take effect and you must wait 14 days before you can
change the storage billing model again.
Set the value to one of ``'LOGICAL'``, ``'PHYSICAL'``, or
``'STORAGE_BILLING_MODEL_UNSPECIFIED'``. This change takes 24 hours to
take effect and you must wait 14 days before you can change the storage
billing model again.

See `storage billing model
<https://cloud.google.com/bigquery/docs/reference/rest/v2/datasets#Dataset.FIELDS.storage_billing_model>`_
Expand All @@ -788,13 +789,11 @@ def storage_billing_model(self):
def storage_billing_model(self, value):
if not isinstance(value, str) and value is not None:
raise ValueError(
"storage_billing_model must be a string (e.g. 'LOGICAL', 'PHYSICAL'), or None. "
f"Got {repr(value)}."
"storage_billing_model must be a string (e.g. 'LOGICAL',"
" 'PHYSICAL', 'STORAGE_BILLING_MODEL_UNSPECIFIED'), or None."
f" Got {repr(value)}."
)
if value:
self._properties["storageBillingModel"] = value
if value is None:
self._properties["storageBillingModel"] = "LOGICAL"
self._properties["storageBillingModel"] = value

@classmethod
def from_string(cls, full_dataset_id: str) -> "Dataset":
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ def test_storage_billing_model_setter(self):
def test_storage_billing_model_setter_with_none(self):
dataset = self._make_one(self.DS_REF)
dataset.storage_billing_model = None
self.assertEqual(dataset.storage_billing_model, "LOGICAL")
self.assertIsNone(dataset.storage_billing_model)

def test_storage_billing_model_setter_with_invalid_type(self):
dataset = self._make_one(self.DS_REF)
Expand Down