File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1160,6 +1160,10 @@ def schema(self):
11601160
11611161 @schema .setter
11621162 def schema (self , value ):
1163+ if value is None :
1164+ self ._del_sub_prop ("schema" )
1165+ return
1166+
11631167 if not all (hasattr (field , "to_api_repr" ) for field in value ):
11641168 raise ValueError ("Schema items must be fields" )
11651169 _helpers ._set_sub_prop (
Original file line number Diff line number Diff line change @@ -1504,6 +1504,19 @@ def test_schema_setter(self):
15041504 config ._properties ["load" ]["schema" ], {"fields" : [full_name_repr , age_repr ]}
15051505 )
15061506
1507+ def test_schema_setter_unsetting_schema (self ):
1508+ from google .cloud .bigquery .schema import SchemaField
1509+
1510+ config = self ._get_target_class ()()
1511+ config ._properties ["load" ]["schema" ] = [
1512+ SchemaField ("full_name" , "STRING" , mode = "REQUIRED" ),
1513+ SchemaField ("age" , "INTEGER" , mode = "REQUIRED" ),
1514+ ]
1515+
1516+ config .schema = None
1517+ self .assertNotIn ("schema" , config ._properties ["load" ])
1518+ config .schema = None # no error, idempotent operation
1519+
15071520 def test_schema_update_options_missing (self ):
15081521 config = self ._get_target_class ()()
15091522 self .assertIsNone (config .schema_update_options )
You can’t perform that action at this time.
0 commit comments