Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 325
feat: add support for decimal target types#735
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,6 +22,7 @@ | ||
| import base64 | ||
| import copy | ||
| from typing import FrozenSet, Iterable, Optional | ||
| from google.cloud.bigquery._helpers import _to_bytes | ||
| from google.cloud.bigquery._helpers import _bytes_to_json | ||
| @@ -693,6 +694,28 @@ def compression(self): | ||
| def compression(self, value): | ||
| self._properties["compression"] = value | ||
| @property | ||
| def decimal_target_types(self) -> Optional[FrozenSet[str]]: | ||
| """Possible SQL data types to which the source decimal values are converted. | ||
| See: | ||
| https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ExternalDataConfiguration.FIELDS.decimal_target_types | ||
| .. versionadded:: 2.21.0 | ||
| """ | ||
| prop = self._properties.get("decimalTargetTypes") | ||
| if prop is not None: | ||
| prop = frozenset(prop) | ||
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. The enum docstrings added above suggest that order is significant. However, ContributorAuthor 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 per docs, the order is not significant, which why a (frozen) set is returned.
The backend always uses the following order: NUMERIC, BIGNUMERIC, and STRING (among the target types provided). I'll re-read the enum docstrings and make them more clear, if necessary. 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. So we are storing it as a list in the setter for compatibility with how the back-end sends it to us? ContributorAuthor 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. It's primarily because sets are not JSON serializable out of the box - ContributorAuthor 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. @shollyman The Should the generated docs follow suit? Or perhaps modify the wording?
| ||
| return prop | ||
| @decimal_target_types.setter | ||
| def decimal_target_types(self, value: Optional[Iterable[str]]): | ||
| if value is not None: | ||
| self._properties["decimalTargetTypes"] = list(value) | ||
| else: | ||
| if "decimalTargetTypes" in self._properties: | ||
| del self._properties["decimalTargetTypes"] | ||
| @property | ||
| def hive_partitioning(self): | ||
| """Optional[:class:`~.external_config.HivePartitioningOptions`]: [Beta] When set, \ | ||
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.
I notice we are missing docs for a bunch of enums. I filed #744 to switch the docs over to module-based docs for this module.