GeezerVison is showing github.com — feat(bigquery): add support of use_avro_logical_types for extract job… · okothchristopher/python-bigquery@d867d71
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: google/cloud/bigquery/job.py +13-1Lines changed: 13 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -1345,7 +1345,7 @@ def time_partitioning(self, value): | 1345 | 1345 | @property | 1346 | 1346 | def use_avro_logical_types(self): | 1347 | 1347 | """bool: For loads of Avro data, governs whether Avro logical types are | 1348 | | - converted to their corresponding BigQuery types(e.g. TIMESTAMP) rather than | | 1348 | + converted to their corresponding BigQuery types (e.g. TIMESTAMP) rather than | 1349 | 1349 | raw types (e.g. INTEGER). | 1350 | 1350 | """ | 1351 | 1351 | return self._get_sub_prop("useAvroLogicalTypes") | @@ -1938,6 +1938,18 @@ def print_header(self): | 1938 | 1938 | def print_header(self, value): | 1939 | 1939 | self._set_sub_prop("printHeader", value) | 1940 | 1940 |
| | 1941 | + @property | | 1942 | + def use_avro_logical_types(self): | | 1943 | + """bool: For loads of Avro data, governs whether Avro logical types are | | 1944 | + converted to their corresponding BigQuery types (e.g. TIMESTAMP) rather than | | 1945 | + raw types (e.g. INTEGER). | | 1946 | + """ | | 1947 | + return self._get_sub_prop("useAvroLogicalTypes") | | 1948 | + | | 1949 | + @use_avro_logical_types.setter | | 1950 | + def use_avro_logical_types(self, value): | | 1951 | + self._set_sub_prop("useAvroLogicalTypes", bool(value)) | | 1952 | + | 1941 | 1953 |
| 1942 | 1954 | class ExtractJob(_AsyncJob): | 1943 | 1955 | """Asynchronous job: extract data from a table into Cloud Storage. | |
Collapse file Copy file name to clipboardExpand all lines: tests/unit/test_job.py +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3036,6 +3036,7 @@ def test_to_api_repr(self): | 3036 | 3036 | config.field_delimiter = "ignored for avro" | 3037 | 3037 | config.print_header = False | 3038 | 3038 | config._properties["extract"]["someNewField"] = "some-value" | | 3039 | + config.use_avro_logical_types = True | 3039 | 3040 | resource = config.to_api_repr() | 3040 | 3041 | self.assertEqual( | 3041 | 3042 | resource, | @@ -3046,6 +3047,7 @@ def test_to_api_repr(self): | 3046 | 3047 | "fieldDelimiter": "ignored for avro", | 3047 | 3048 | "printHeader": False, | 3048 | 3049 | "someNewField": "some-value", | | 3050 | + "useAvroLogicalTypes": True, | 3049 | 3051 | } | 3050 | 3052 | }, | 3051 | 3053 | ) | @@ -3060,6 +3062,7 @@ def test_from_api_repr(self): | 3060 | 3062 | "fieldDelimiter": "\t", | 3061 | 3063 | "printHeader": True, | 3062 | 3064 | "someNewField": "some-value", | | 3065 | + "useAvroLogicalTypes": False, | 3063 | 3066 | } | 3064 | 3067 | } | 3065 | 3068 | ) | @@ -3068,6 +3071,7 @@ def test_from_api_repr(self): | 3068 | 3071 | self.assertEqual(config.field_delimiter, "\t") | 3069 | 3072 | self.assertEqual(config.print_header, True) | 3070 | 3073 | self.assertEqual(config._properties["extract"]["someNewField"], "some-value") | | 3074 | + self.assertEqual(config.use_avro_logical_types, False) | 3071 | 3075 |
| 3072 | 3076 |
| 3073 | 3077 | class TestExtractJob(unittest.TestCase, _Base): | |
|