|
18 | 18 | Job.configuration.query.tableDefinitions. |
19 | 19 | """ |
20 | 20 |
|
21 | | -from __future__ import absolute_import |
| 21 | +from __future__ import absolute_import, annotations |
22 | 22 |
|
23 | 23 | import base64 |
24 | 24 | import copy |
|
28 | 28 | from google.cloud.bigquery._helpers import _bytes_to_json |
29 | 29 | from google.cloud.bigquery._helpers import _int_or_none |
30 | 30 | from google.cloud.bigquery._helpers import _str_or_none |
| 31 | +from google.cloud.bigquery import _helpers |
31 | 32 | from google.cloud.bigquery.format_options import AvroOptions, ParquetOptions |
32 | 33 | from google.cloud.bigquery.schema import SchemaField |
33 | 34 |
|
@@ -1003,3 +1004,76 @@ def from_api_repr(cls, resource: dict) -> "ExternalConfig": |
1003 | 1004 | config = cls(resource["sourceFormat"]) |
1004 | 1005 | config._properties = copy.deepcopy(resource) |
1005 | 1006 | return config |
| 1007 | + |
| 1008 | + |
| 1009 | +class ExternalCatalogDatasetOptions: |
| 1010 | + """Options defining open source compatible datasets living in the BigQuery catalog. |
| 1011 | + Contains metadata of open source database, schema or namespace represented |
| 1012 | + by the current dataset. |
| 1013 | +
|
| 1014 | + Args: |
| 1015 | + default_storage_location_uri (Optional[str]): The storage location URI for all |
| 1016 | + tables in the dataset. Equivalent to hive metastore's database |
| 1017 | + locationUri. Maximum length of 1024 characters. (str) |
| 1018 | + parameters (Optional[dict[str, Any]]): A map of key value pairs defining the parameters |
| 1019 | + and properties of the open source schema. Maximum size of 2Mib. |
| 1020 | + """ |
| 1021 | + |
| 1022 | + def __init__( |
| 1023 | + self, |
| 1024 | + default_storage_location_uri: Optional[str] = None, |
| 1025 | + parameters: Optional[Dict[str, Any]] = None, |
| 1026 | + ): |
| 1027 | + self._properties: Dict[str, Any] = {} |
| 1028 | + self.default_storage_location_uri = default_storage_location_uri |
| 1029 | + self.parameters = parameters |
| 1030 | + |
| 1031 | + @property |
| 1032 | + def default_storage_location_uri(self) -> Optional[str]: |
| 1033 | + """Optional. The storage location URI for all tables in the dataset. |
| 1034 | + Equivalent to hive metastore's database locationUri. Maximum length of |
| 1035 | + 1024 characters.""" |
| 1036 | + |
| 1037 | + return self._properties.get("defaultStorageLocationUri") |
| 1038 | + |
| 1039 | + @default_storage_location_uri.setter |
| 1040 | + def default_storage_location_uri(self, value: Optional[str]): |
| 1041 | + value = _helpers._isinstance_or_raise(value, str, none_allowed=True) |
| 1042 | + self._properties["defaultStorageLocationUri"] = value |
| 1043 | + |
| 1044 | + @property |
| 1045 | + def parameters(self) -> Optional[Dict[str, Any]]: |
| 1046 | + """Optional. A map of key value pairs defining the parameters and |
| 1047 | + properties of the open source schema. Maximum size of 2Mib.""" |
| 1048 | + |
| 1049 | + return self._properties.get("parameters") |
| 1050 | + |
| 1051 | + @parameters.setter |
| 1052 | + def parameters(self, value: Optional[Dict[str, Any]]): |
| 1053 | + value = _helpers._isinstance_or_raise(value, dict, none_allowed=True) |
| 1054 | + self._properties["parameters"] = value |
| 1055 | + |
| 1056 | + def to_api_repr(self) -> dict: |
| 1057 | + """Build an API representation of this object. |
| 1058 | +
|
| 1059 | + Returns: |
| 1060 | + Dict[str, Any]: |
| 1061 | + A dictionary in the format used by the BigQuery API. |
| 1062 | + """ |
| 1063 | + return self._properties |
| 1064 | + |
| 1065 | + @classmethod |
| 1066 | + def from_api_repr(cls, api_repr: dict) -> ExternalCatalogDatasetOptions: |
| 1067 | + """Factory: constructs an instance of the class (cls) |
| 1068 | + given its API representation. |
| 1069 | +
|
| 1070 | + Args: |
| 1071 | + api_repr (Dict[str, Any]): |
| 1072 | + API representation of the object to be instantiated. |
| 1073 | +
|
| 1074 | + Returns: |
| 1075 | + An instance of the class initialized with data from 'resource'. |
| 1076 | + """ |
| 1077 | + config = cls() |
| 1078 | + config._properties = api_repr |
| 1079 | + return config |
0 commit comments