Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/google/cloud/bigquery/format_options.py: 64%
44 statements
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:07 +0000
« prev ^ index » next coverage.py v7.2.2, created at 2023-03-26 06:07 +0000
1# Copyright 2021 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
15import copy
16from typing import Dict, Optional
19class AvroOptions:
20 """Options if source format is set to AVRO."""
22 _SOURCE_FORMAT = "AVRO"
23 _RESOURCE_NAME = "avroOptions"
25 def __init__(self):
26 self._properties = {}
28 @property
29 def use_avro_logical_types(self) -> Optional[bool]:
30 """[Optional] If sourceFormat is set to 'AVRO', indicates whether to
31 interpret logical types as the corresponding BigQuery data type (for
32 example, TIMESTAMP), instead of using the raw type (for example,
33 INTEGER).
35 See
36 https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#AvroOptions.FIELDS.use_avro_logical_types
37 """
38 return self._properties.get("useAvroLogicalTypes")
40 @use_avro_logical_types.setter
41 def use_avro_logical_types(self, value):
42 self._properties["useAvroLogicalTypes"] = value
44 @classmethod
45 def from_api_repr(cls, resource: Dict[str, bool]) -> "AvroOptions":
46 """Factory: construct an instance from a resource dict.
48 Args:
49 resource (Dict[str, bool]):
50 Definition of a :class:`~.format_options.AvroOptions` instance in
51 the same representation as is returned from the API.
53 Returns:
54 :class:`~.format_options.AvroOptions`:
55 Configuration parsed from ``resource``.
56 """
57 config = cls()
58 config._properties = copy.deepcopy(resource)
59 return config
61 def to_api_repr(self) -> dict:
62 """Build an API representation of this object.
64 Returns:
65 Dict[str, bool]:
66 A dictionary in the format used by the BigQuery API.
67 """
68 return copy.deepcopy(self._properties)
71class ParquetOptions:
72 """Additional options if the PARQUET source format is used."""
74 _SOURCE_FORMAT = "PARQUET"
75 _RESOURCE_NAME = "parquetOptions"
77 def __init__(self):
78 self._properties = {}
80 @property
81 def enum_as_string(self) -> bool:
82 """Indicates whether to infer Parquet ENUM logical type as STRING instead of
83 BYTES by default.
85 See
86 https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ParquetOptions.FIELDS.enum_as_string
87 """
88 return self._properties.get("enumAsString")
90 @enum_as_string.setter
91 def enum_as_string(self, value: bool) -> None:
92 self._properties["enumAsString"] = value
94 @property
95 def enable_list_inference(self) -> bool:
96 """Indicates whether to use schema inference specifically for Parquet LIST
97 logical type.
99 See
100 https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#ParquetOptions.FIELDS.enable_list_inference
101 """
102 return self._properties.get("enableListInference")
104 @enable_list_inference.setter
105 def enable_list_inference(self, value: bool) -> None:
106 self._properties["enableListInference"] = value
108 @classmethod
109 def from_api_repr(cls, resource: Dict[str, bool]) -> "ParquetOptions":
110 """Factory: construct an instance from a resource dict.
112 Args:
113 resource (Dict[str, bool]):
114 Definition of a :class:`~.format_options.ParquetOptions` instance in
115 the same representation as is returned from the API.
117 Returns:
118 :class:`~.format_options.ParquetOptions`:
119 Configuration parsed from ``resource``.
120 """
121 config = cls()
122 config._properties = copy.deepcopy(resource)
123 return config
125 def to_api_repr(self) -> dict:
126 """Build an API representation of this object.
128 Returns:
129 Dict[str, bool]:
130 A dictionary in the format used by the BigQuery API.
131 """
132 return copy.deepcopy(self._properties)