Skip to content

Commit

Permalink
Updates external_catalog_dataset functions in dataset.py and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
chalmerlowe committed Nov 4, 2024
1 parent 0ce7f9c commit 3867638
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
10 changes: 1 addition & 9 deletions google/cloud/bigquery/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -950,18 +950,11 @@ def external_catalog_dataset_options(self):
prop = _helpers._get_sub_prop(
self._properties, ["externalCatalogDatasetOptions"]
)
# self._PROPERTY_TO_API_FIELD["external_catalog_dataset_options"]
# )

if prop is not None:
prop = ExternalCatalogDatasetOptions().from_api_repr(prop)
print("DINOSAUR dataset.py prop: ", prop, type(prop))
return prop

# prop = self._get_sub_prop("destinationEncryptionConfiguration")
# if prop is not None:
# prop = EncryptionConfiguration.from_api_repr(prop)
# return prop

@external_catalog_dataset_options.setter
def external_catalog_dataset_options(self, value):
Expand All @@ -970,10 +963,9 @@ def external_catalog_dataset_options(self, value):
self._PROPERTY_TO_API_FIELD["external_catalog_dataset_options"]
] = value.to_api_repr()

table = _get_table_reference

table = _get_table_reference
model = _get_model_reference

routine = _get_routine_reference

def __repr__(self):
Expand Down
26 changes: 12 additions & 14 deletions tests/unit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,13 +1027,12 @@ def test_external_catalog_dataset_options_setter(self):
from google.cloud.bigquery.external_config import ExternalCatalogDatasetOptions

dataset = self._make_one(self.DS_REF)
external_dataset_catalog_options = ExternalCatalogDatasetOptions(
ecdo_obj = ExternalCatalogDatasetOptions(
default_storage_location_uri="gs://test-bucket/test-path",
parameters={"key": "value"},
)

# test the setter
dataset.external_catalog_dataset_options = external_dataset_catalog_options
dataset.external_catalog_dataset_options = ecdo_obj
expected = self.API_REPR
result = dataset.to_api_repr()
assert result == expected
Expand All @@ -1042,26 +1041,25 @@ def test_external_catalog_dataset_options_getter(self):
from google.cloud.bigquery.external_config import ExternalCatalogDatasetOptions

dataset = self._make_one(self.DS_REF)
external_dataset_catalog_options = ExternalCatalogDatasetOptions(
ecdo_obj = ExternalCatalogDatasetOptions(
default_storage_location_uri="gs://test-bucket/test-path",
parameters={"key": "value"},
)
dataset.external_catalog_dataset_options = external_dataset_catalog_options
print("DINOSAUR test_dataset.py dataset: ", dataset, type(dataset))
expected = external_dataset_catalog_options
result = dataset.external_catalog_dataset_options

dataset.external_catalog_dataset_options = ecdo_obj
expected = ecdo_obj._properties
result = dataset.external_catalog_dataset_options._properties

assert result == expected

def test_external_catalog_dataset_options_from_api_repr(self):
from google.cloud.bigquery.external_config import ExternalCatalogDatasetOptions

resource = self.API_REPR

dataset = self._make_one(self.DS_REF)
dataset = dataset.from_api_repr(resource)
result = dataset.external_catalog_dataset_options
assert result == resource["externalCatalogDatasetOptions"]
klass = self._get_target_class()
dataset = klass.from_api_repr(resource)
result = dataset.external_catalog_dataset_options._properties
expected = resource["externalCatalogDatasetOptions"]
assert result == expected

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

0 comments on commit 3867638

Please sign in to comment.