@@ -380,6 +380,11 @@ def _verifyEnumConfigProperties(self, job, config):
380380 config ['writeDisposition' ])
381381 else :
382382 self .assertIsNone (job .write_disposition )
383+ if 'schemaUpdateOptions' in config :
384+ self .assertEqual (
385+ job .schema_update_options , config ['schemaUpdateOptions' ])
386+ else :
387+ self .assertIsNone (job .schema_update_options )
383388
384389 def _verifyResourceProperties (self , job , resource ):
385390 self ._verifyReadonlyResourceProperties (job , resource )
@@ -467,6 +472,7 @@ def test_ctor(self):
467472 self .assertIsNone (job .write_disposition )
468473 self .assertIsNone (job .destination_encryption_configuration )
469474 self .assertIsNone (job .time_partitioning )
475+ self .assertIsNone (job .schema_update_options )
470476
471477 def test_ctor_w_config (self ):
472478 from google .cloud .bigquery .schema import SchemaField
@@ -780,6 +786,7 @@ def test_begin_w_autodetect(self):
780786
781787 def test_begin_w_alternate_client (self ):
782788 from google .cloud .bigquery .job import CreateDisposition
789+ from google .cloud .bigquery .job import SchemaUpdateOption
783790 from google .cloud .bigquery .job import WriteDisposition
784791 from google .cloud .bigquery .schema import SchemaField
785792
@@ -817,7 +824,10 @@ def test_begin_w_alternate_client(self):
817824 'mode' : 'REQUIRED' ,
818825 'description' : None ,
819826 },
820- ]}
827+ ]},
828+ 'schemaUpdateOptions' : [
829+ SchemaUpdateOption .ALLOW_FIELD_ADDITION ,
830+ ],
821831 }
822832 RESOURCE ['configuration' ]['load' ] = LOAD_CONFIGURATION
823833 conn1 = _make_connection ()
@@ -842,6 +852,9 @@ def test_begin_w_alternate_client(self):
842852 config .skip_leading_rows = 1
843853 config .source_format = 'CSV'
844854 config .write_disposition = WriteDisposition .WRITE_TRUNCATE
855+ config .schema_update_options = [
856+ SchemaUpdateOption .ALLOW_FIELD_ADDITION ,
857+ ]
845858
846859 job ._begin (client = client2 )
847860
@@ -2127,6 +2140,11 @@ def _verifyResourceProperties(self, job, resource):
21272140 'kmsKeyName' ])
21282141 else :
21292142 self .assertIsNone (job .destination_encryption_configuration )
2143+ if 'schemaUpdateOptions' in query_config :
2144+ self .assertEqual (
2145+ job .schema_update_options , query_config ['schemaUpdateOptions' ])
2146+ else :
2147+ self .assertIsNone (job .schema_update_options )
21302148
21312149 def test_ctor_defaults (self ):
21322150 client = _make_client (project = self .PROJECT )
@@ -2157,6 +2175,7 @@ def test_ctor_defaults(self):
21572175 self .assertIsNone (job .table_definitions )
21582176 self .assertIsNone (job .destination_encryption_configuration )
21592177 self .assertIsNone (job .time_partitioning )
2178+ self .assertIsNone (job .schema_update_options )
21602179
21612180 def test_ctor_w_udf_resources (self ):
21622181 from google .cloud .bigquery .job import QueryJobConfig
@@ -2248,6 +2267,7 @@ def test_from_api_repr_with_encryption(self):
22482267
22492268 def test_from_api_repr_w_properties (self ):
22502269 from google .cloud .bigquery .job import CreateDisposition
2270+ from google .cloud .bigquery .job import SchemaUpdateOption
22512271 from google .cloud .bigquery .job import WriteDisposition
22522272
22532273 client = _make_client (project = self .PROJECT )
@@ -2260,6 +2280,9 @@ def test_from_api_repr_w_properties(self):
22602280 'datasetId' : self .DS_ID ,
22612281 'tableId' : self .DESTINATION_TABLE ,
22622282 }
2283+ query_config ['schemaUpdateOptions' ] = [
2284+ SchemaUpdateOption .ALLOW_FIELD_ADDITION ,
2285+ ]
22632286 klass = self ._get_target_class ()
22642287 job = klass .from_api_repr (RESOURCE , client = client )
22652288 self .assertIs (job ._client , client )
@@ -2841,6 +2864,7 @@ def test_begin_w_alternate_client(self):
28412864 from google .cloud .bigquery .job import CreateDisposition
28422865 from google .cloud .bigquery .job import QueryJobConfig
28432866 from google .cloud .bigquery .job import QueryPriority
2867+ from google .cloud .bigquery .job import SchemaUpdateOption
28442868 from google .cloud .bigquery .job import WriteDisposition
28452869
28462870 PATH = '/projects/%s/jobs' % (self .PROJECT ,)
@@ -2866,7 +2890,10 @@ def test_begin_w_alternate_client(self):
28662890 'useLegacySql' : True ,
28672891 'writeDisposition' : WriteDisposition .WRITE_TRUNCATE ,
28682892 'maximumBillingTier' : 4 ,
2869- 'maximumBytesBilled' : '123456'
2893+ 'maximumBytesBilled' : '123456' ,
2894+ 'schemaUpdateOptions' : [
2895+ SchemaUpdateOption .ALLOW_FIELD_RELAXATION ,
2896+ ]
28702897 }
28712898 RESOURCE ['configuration' ]['query' ] = QUERY_CONFIGURATION
28722899 RESOURCE ['configuration' ]['dryRun' ] = True
@@ -2890,6 +2917,9 @@ def test_begin_w_alternate_client(self):
28902917 config .use_query_cache = True
28912918 config .write_disposition = WriteDisposition .WRITE_TRUNCATE
28922919 config .maximum_bytes_billed = 123456
2920+ config .schema_update_options = [
2921+ SchemaUpdateOption .ALLOW_FIELD_RELAXATION ,
2922+ ]
28932923 job = self ._make_one (
28942924 self .JOB_ID , self .QUERY , client1 , job_config = config )
28952925
0 commit comments