Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Merged
Changes from 1 commit
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
Prev Previous commit
updates attr names, corrects type hinting
  • Loading branch information
chalmerlowe committed Jan 14, 2025
commit 23874af00dc4f564ebb0b26e5cce291936ffc99e
28 changes: 16 additions & 12 deletions google/cloud/bigquery/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,20 +649,21 @@ def from_api_repr(cls, api_repr: dict) -> SerDeInfo:
class StorageDescriptor:
"""Contains information about how a table's data is stored and accessed by open
source query engines.

Args:
inputFormat (Optional[str]): Specifies the fully qualified class name of
input_format (Optional[str]): Specifies the fully qualified class name of
the InputFormat (e.g.
"org.apache.hadoop.hive.ql.io.orc.OrcInputFormat"). The maximum
length is 128 characters.
locationUri (Optional[str]): The physical location of the table (e.g.
location_uri (Optional[str]): The physical location of the table (e.g.
'gs://spark-dataproc-data/pangea-data/case_sensitive/' or
'gs://spark-dataproc-data/pangea-data/'). The maximum length is
2056 bytes.
outputFormat (Optional[str]): Specifies the fully qualified class name
output_format (Optional[str]): Specifies the fully qualified class name
of the OutputFormat (e.g.
"org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat"). The maximum
length is 128 characters.
serdeInfo (Union[SerDeInfo, dict, None]): Serializer and deserializer information.
serde_info (Union[SerDeInfo, dict, None]): Serializer and deserializer information.
"""

def __init__(
Expand All @@ -676,7 +677,10 @@ def __init__(
self.input_format = input_format
self.location_uri = location_uri
self.output_format = output_format
self.serde_info = serde_info
# Using typing.cast() because mypy cannot wrap it's head around the fact that:
# the setter can accept Union[SerDeInfo, dict, None]
# but the getter will only ever return Optional[SerDeInfo].
self.serde_info = typing.cast(Optional[SerDeInfo], serde_info)

@property
def input_format(self) -> Optional[str]:
Expand Down Expand Up @@ -718,24 +722,24 @@ def output_format(self, value: Optional[str]):
self._properties["outputFormat"] = value

@property
def serde_info(self) -> Union[SerDeInfo, dict, None]:
def serde_info(self) -> Optional[SerDeInfo]:
"""Optional. Serializer and deserializer information."""

prop = _helpers._get_sub_prop(self._properties, ["serDeInfo"])
if prop is not None:
prop = SerDeInfo("PLACEHOLDER").from_api_repr(prop)
return prop
return typing.cast(SerDeInfo, SerDeInfo.from_api_repr(prop))
return None

@serde_info.setter
def serde_info(self, value: Union[SerDeInfo, dict, None]):
value = _helpers._isinstance_or_raise(
value, (SerDeInfo, dict), none_allowed=True
)

if value is not None:
if isinstance(value, SerDeInfo):
value = value.to_api_repr()
self._properties["serDeInfo"] = value
if isinstance(value, SerDeInfo):
self._properties["serDeInfo"] = value.to_api_repr()
else:
self._properties["serDeInfo"] = value

def to_api_repr(self) -> dict:
"""Build an API representation of this object.
Expand Down