-
Notifications
You must be signed in to change notification settings - Fork 324
feat: adds the SerDeInfo class and tests #2108
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,13 +17,11 @@ | |||||||||||
| from __future__ import annotations | ||||||||||||
| import collections | ||||||||||||
| import enum | ||||||||||||
| import typing | ||||||||||||
| from typing import Any, cast, Dict, Iterable, Optional, Union | ||||||||||||
|
|
||||||||||||
| from google.cloud.bigquery import _helpers | ||||||||||||
| from google.cloud.bigquery import standard_sql | ||||||||||||
| from google.cloud.bigquery._helpers import ( | ||||||||||||
| _isinstance_or_raise, | ||||||||||||
| ) | ||||||||||||
| from google.cloud.bigquery.enums import StandardSqlTypeNames | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
@@ -564,8 +562,9 @@ def to_api_repr(self) -> dict: | |||||||||||
|
|
||||||||||||
| class SerDeInfo: | ||||||||||||
| """Serializer and deserializer information. | ||||||||||||
|
|
||||||||||||
| Args: | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might need a blank line here for the docs renderer to work?
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Resolved. |
||||||||||||
| serializationLibrary (str): Required. Specifies a fully-qualified class | ||||||||||||
| serialization_library (str): Required. Specifies a fully-qualified class | ||||||||||||
| name of the serialization library that is responsible for the | ||||||||||||
| translation of data between table representation and the underlying | ||||||||||||
| low-level input and output format structures. The maximum length is | ||||||||||||
|
|
@@ -588,40 +587,40 @@ def __init__( | |||||||||||
| self.parameters = parameters | ||||||||||||
|
|
||||||||||||
| @property | ||||||||||||
| def serialization_library(self) -> Any: | ||||||||||||
| def serialization_library(self) -> str: | ||||||||||||
| """Required. Specifies a fully-qualified class name of the serialization | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in chat, I prefer to leave this as is. |
||||||||||||
| library that is responsible for the translation of data between table | ||||||||||||
| representation and the underlying low-level input and output format | ||||||||||||
| structures. The maximum length is 256 characters.""" | ||||||||||||
|
|
||||||||||||
| return self._properties.get("serializationLibrary") | ||||||||||||
| return typing.cast(str, self._properties.get("serializationLibrary")) | ||||||||||||
|
|
||||||||||||
| @serialization_library.setter | ||||||||||||
| def serialization_library(self, value: str): | ||||||||||||
| value = _isinstance_or_raise(value, str, none_allowed=False) | ||||||||||||
| value = _helpers._isinstance_or_raise(value, str, none_allowed=False) | ||||||||||||
| self._properties["serializationLibrary"] = value | ||||||||||||
|
|
||||||||||||
| @property | ||||||||||||
| def name(self) -> Any: | ||||||||||||
| def name(self) -> Optional[str]: | ||||||||||||
| """Optional. Name of the SerDe. The maximum length is 256 characters.""" | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: similarly, we can remove
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As mentioned in chat, I prefer to leave this as is. |
||||||||||||
|
|
||||||||||||
| return self._properties.get("name") | ||||||||||||
|
|
||||||||||||
| @name.setter | ||||||||||||
| def name(self, value: Optional[str] = None): | ||||||||||||
|
Linchin marked this conversation as resolved.
|
||||||||||||
| value = _isinstance_or_raise(value, str, none_allowed=True) | ||||||||||||
| value = _helpers._isinstance_or_raise(value, str, none_allowed=True) | ||||||||||||
| self._properties["name"] = value | ||||||||||||
|
|
||||||||||||
| @property | ||||||||||||
| def parameters(self) -> Any: | ||||||||||||
| def parameters(self) -> Optional[dict[str, str]]: | ||||||||||||
| """Optional. Key-value pairs that define the initialization parameters | ||||||||||||
| for the serialization library. Maximum size 10 Kib.""" | ||||||||||||
|
|
||||||||||||
| return self._properties.get("parameters") | ||||||||||||
|
|
||||||||||||
| @parameters.setter | ||||||||||||
| def parameters(self, value: Optional[dict[str, str]] = None): | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See reply above from Python Docs about the concept of optional versus |
||||||||||||
| value = _isinstance_or_raise(value, dict, none_allowed=True) | ||||||||||||
| value = _helpers._isinstance_or_raise(value, dict, none_allowed=True) | ||||||||||||
| self._properties["parameters"] = value | ||||||||||||
|
|
||||||||||||
| def to_api_repr(self) -> dict: | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the name in the REST API? I'd prefer the full names rather than abbreviations, but I'm OK with this if it's to be consistent with the proto/REST API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SerDeInfois the name in the proto/REST API definitions.