Skip to content

Commit c17b6de

Browse files
committed
adds date_format to new to/from_api_repr tests
1 parent fe75a18 commit c17b6de

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

google/cloud/bigquery/external_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ def date_format(self) -> Optional[str]:
862862
def date_format(self, value: Optional[str]):
863863
self._properties["dateFormat"] = value
864864

865+
@property
865866
def time_zone(self) -> Optional[str]:
866867
"""Optional[str]: Time zone used when parsing timestamp values that do not
867868
have specific time zone information (e.g. 2024-04-20 12:34:56). The expected

google/cloud/bigquery/job/load.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ def date_format(self) -> Optional[str]:
561561
def date_format(self, value: Optional[str]):
562562
self._set_sub_prop("dateFormat", value)
563563

564+
@property
564565
def time_zone(self) -> Optional[str]:
565566
"""Optional[str]: Default time zone that will apply when parsing timestamp
566567
values that have no specific time zone.
@@ -922,6 +923,7 @@ def date_format(self):
922923
"""
923924
return self.configuration.date_format
924925

926+
@property
925927
def time_zone(self):
926928
"""See
927929
:attr:`google.cloud.bigquery.job.LoadJobConfig.time_zone`.

tests/unit/job/test_load.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ def _verifyResourceProperties(self, job, resource):
147147
)
148148
else:
149149
self.assertIsNone(job.reference_file_schema_uri)
150-
151150
if "destinationEncryptionConfiguration" in config:
152151
self.assertIsNotNone(job.destination_encryption_configuration)
153152
self.assertEqual(
@@ -156,15 +155,14 @@ def _verifyResourceProperties(self, job, resource):
156155
)
157156
else:
158157
self.assertIsNone(job.destination_encryption_configuration)
159-
if "timeZone" in config:
160-
self.assertEqual(job.time_zone, config["timeZone"])
161-
else:
162-
self.assertIsNone(job.time_zone)
163-
164158
if "dateFormat" in config:
165159
self.assertEqual(job.date_format, config["dateFormat"])
166160
else:
167161
self.assertIsNone(job.date_format)
162+
if "timeZone" in config:
163+
self.assertEqual(job.time_zone, config["timeZone"])
164+
else:
165+
self.assertIsNone(job.time_zone)
168166

169167
def test_ctor(self):
170168
client = _make_client(project=self.PROJECT)

tests/unit/job/test_load_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,7 @@ def test_column_name_character_map_none(self):
958958
},
959959
"useAvroLogicalTypes": True,
960960
"writeDisposition": "WRITE_TRUNCATE",
961+
"dateFormat": "%Y-%m-%d",
961962
"timeZone": "America/New_York",
962963
"parquetOptions": {"enableListInference": True},
963964
"columnNameCharacterMap": "V2",
@@ -999,6 +1000,7 @@ def test_from_api_repr(self):
9991000
)
10001001
self.assertTrue(config.use_avro_logical_types)
10011002
self.assertEqual(config.write_disposition, WriteDisposition.WRITE_TRUNCATE)
1003+
self.assertEqual(config.date_format, "%Y-%m-%d")
10021004
self.assertEqual(config.time_zone, "America/New_York")
10031005
self.assertTrue(config.parquet_options.enable_list_inference)
10041006
self.assertEqual(config.column_name_character_map, ColumnNameCharacterMap.V2)
@@ -1033,6 +1035,7 @@ def test_to_api_repr(self):
10331035
)
10341036
config.use_avro_logical_types = True
10351037
config.write_disposition = WriteDisposition.WRITE_TRUNCATE
1038+
config.date_format = "%Y-%m-%d"
10361039
config.time_zone = "America/New_York"
10371040
parquet_options = ParquetOptions()
10381041
parquet_options.enable_list_inference = True

0 commit comments

Comments
 (0)