@@ -985,6 +985,8 @@ def test_update_table_autodetect_schema(self):
985
985
TABLE_NAME = "test_table"
986
986
set_schema = [bigquery .SchemaField ("username" , "STRING" , mode = "NULLABLE" )]
987
987
table_arg = Table (dataset .table (TABLE_NAME ))
988
+
989
+ # Create an external_config and include it in the table arguments
988
990
external_config = bigquery .ExternalConfig (bigquery .ExternalSourceFormat .AVRO )
989
991
external_config .source_uris = SOURCE_URIS_AVRO
990
992
external_config .reference_file_schema_uri = REFERENCE_FILE_SCHEMA_URI_AVRO
@@ -1001,13 +1003,9 @@ def test_update_table_autodetect_schema(self):
1001
1003
1002
1004
# Update table with schema autodetection
1003
1005
updated_table_arg = Table (dataset .table (TABLE_NAME ))
1004
- updated_external_config = bigquery .ExternalConfig (
1005
- bigquery .ExternalSourceFormat .AVRO
1006
- )
1007
- updated_external_config .source_uris = SOURCE_URIS_AVRO
1008
- updated_external_config .reference_file_schema_uri = (
1009
- REFERENCE_FILE_SCHEMA_URI_AVRO
1010
- )
1006
+
1007
+ # Update the external_config and include it in the updated table arguments
1008
+ updated_external_config = copy .deepcopy (external_config )
1011
1009
updated_external_config .autodetect = True
1012
1010
updated_external_config .schema = None
1013
1011
updated_table_arg .external_data_configuration = updated_external_config
@@ -1016,7 +1014,7 @@ def test_update_table_autodetect_schema(self):
1016
1014
updated_table_arg , ["external_data_configuration" ], autodetect_schema = True
1017
1015
)
1018
1016
1019
- # The updated table shlould have a schema inferred from the reference
1017
+ # The updated table should have a schema inferred from the reference
1020
1018
# file, which has all four fields.
1021
1019
expected_schema = [
1022
1020
bigquery .SchemaField ("username" , "STRING" , mode = "NULLABLE" ),
0 commit comments