@@ -40,15 +40,22 @@ def _setUpConstants(self):
4040 self .REFERENCE_FILE_SCHEMA_URI = "gs://path/to/reference"
4141 self .SOURCE_COLUMN_MATCH = "NAME"
4242 self .DATE_FORMAT = "%Y-%m-%d"
43+ self .DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
4344 self .TIME_ZONE = "UTC"
45+ self .TIME_FORMAT = "%H:%M:%S"
46+ self .TIMESTAMP_FORMAT = "YYYY-MM-DD HH:MM:SS.SSSSSSZ"
4447
4548 def _make_resource (self , started = False , ended = False ):
4649 resource = super (TestLoadJob , self )._make_resource (started , ended )
4750 config = resource ["configuration" ]["load" ]
4851 config ["sourceUris" ] = [self .SOURCE1 ]
4952 config ["sourceColumnMatch" ] = self .SOURCE_COLUMN_MATCH
5053 config ["dateFormat" ] = self .DATE_FORMAT
54+ config ["datetimeFormat" ] = self .DATETIME_FORMAT
5155 config ["timeZone" ] = self .TIME_ZONE
56+ config ["timeFormat" ] = self .TIME_FORMAT
57+ config ["timestampFormat" ] = self .TIMESTAMP_FORMAT
58+
5259 config ["destinationTable" ] = {
5360 "projectId" : self .PROJECT ,
5461 "datasetId" : self .DS_ID ,
@@ -162,10 +169,22 @@ def _verifyResourceProperties(self, job, resource):
162169 self .assertEqual (job .date_format , config ["dateFormat" ])
163170 else :
164171 self .assertIsNone (job .date_format )
172+ if "datetimeFormat" in config :
173+ self .assertEqual (job .datetime_format , config ["datetimeFormat" ])
174+ else :
175+ self .assertIsNone (job .datetime_format )
165176 if "timeZone" in config :
166177 self .assertEqual (job .time_zone , config ["timeZone" ])
167178 else :
168179 self .assertIsNone (job .time_zone )
180+ if "timeFormat" in config :
181+ self .assertEqual (job .time_format , config ["timeFormat" ])
182+ else :
183+ self .assertIsNone (job .time_format )
184+ if "timestampFormat" in config :
185+ self .assertEqual (job .timestamp_format , config ["timestampFormat" ])
186+ else :
187+ self .assertIsNone (job .timestamp_format )
169188
170189 if "sourceColumnMatch" in config :
171190 # job.source_column_match will be an Enum, config[...] is a string
@@ -219,7 +238,10 @@ def test_ctor(self):
219238 self .assertIsNone (job .reference_file_schema_uri )
220239 self .assertIsNone (job .source_column_match )
221240 self .assertIsNone (job .date_format )
241+ self .assertIsNone (job .datetime_format )
222242 self .assertIsNone (job .time_zone )
243+ self .assertIsNone (job .time_format )
244+ self .assertIsNone (job .timestamp_format )
223245
224246 def test_ctor_w_config (self ):
225247 from google .cloud .bigquery .schema import SchemaField
@@ -617,8 +639,12 @@ def test_begin_w_alternate_client(self):
617639 "schemaUpdateOptions" : [SchemaUpdateOption .ALLOW_FIELD_ADDITION ],
618640 "sourceColumnMatch" : self .SOURCE_COLUMN_MATCH ,
619641 "dateFormat" : self .DATE_FORMAT ,
642+ "datetimeFormat" : self .DATETIME_FORMAT ,
620643 "timeZone" : self .TIME_ZONE ,
644+ "timeFormat" : self .TIME_FORMAT ,
645+ "timestampFormat" : self .TIMESTAMP_FORMAT ,
621646 }
647+
622648 RESOURCE ["configuration" ]["load" ] = LOAD_CONFIGURATION
623649 conn1 = make_connection ()
624650 client1 = _make_client (project = self .PROJECT , connection = conn1 )
@@ -648,7 +674,10 @@ def test_begin_w_alternate_client(self):
648674 config .reference_file_schema_uri = "gs://path/to/reference"
649675 config .source_column_match = SourceColumnMatch (self .SOURCE_COLUMN_MATCH )
650676 config .date_format = self .DATE_FORMAT
677+ config .datetime_format = self .DATETIME_FORMAT
651678 config .time_zone = self .TIME_ZONE
679+ config .time_format = self .TIME_FORMAT
680+ config .timestamp_format = self .TIMESTAMP_FORMAT
652681
653682 with mock .patch (
654683 "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes"
0 commit comments