5757from google .cloud .bigquery ._helpers import _record_field_to_json
5858from google .cloud .bigquery ._helpers import _str_or_none
5959from google .cloud .bigquery ._helpers import _verify_job_config_type
60+ from google .cloud .bigquery ._helpers import _del_sub_prop
6061from google .cloud .bigquery ._http import Connection
6162from google .cloud .bigquery import _pandas_helpers
6263from google .cloud .bigquery .dataset import Dataset
@@ -1338,9 +1339,7 @@ def create_job(self, job_config, retry=DEFAULT_RETRY):
13381339 load_job_config = google .cloud .bigquery .job .LoadJobConfig .from_api_repr (
13391340 job_config
13401341 )
1341- destination = TableReference .from_api_repr (
1342- job_config ["load" ]["destinationTable" ]
1343- )
1342+ destination = _get_sub_prop (job_config , ["load" , "destinationTable" ])
13441343 source_uris = _get_sub_prop (job_config , ["load" , "sourceUris" ])
13451344 return self .load_table_from_uri (
13461345 source_uris , destination , job_config = load_job_config , retry = retry
@@ -1349,14 +1348,12 @@ def create_job(self, job_config, retry=DEFAULT_RETRY):
13491348 copy_job_config = google .cloud .bigquery .job .CopyJobConfig .from_api_repr (
13501349 job_config
13511350 )
1352- copy_resource = job_config ["copy" ]
1353- destination = TableReference .from_api_repr (
1354- copy_resource ["destinationTable" ]
1355- )
1351+ destination = _get_sub_prop (job_config , ["copy" , "destinationTable" ])
13561352 sources = []
1357- source_configs = copy_resource .get ("sourceTables" )
1353+ source_configs = _get_sub_prop (job_config , ["copy" , "sourceTables" ])
1354+
13581355 if source_configs is None :
1359- source_configs = [copy_resource [ " sourceTable" ]]
1356+ source_configs = [_get_sub_prop ( job_config , [ "copy" , " sourceTable" ]) ]
13601357 for source_config in source_configs :
13611358 table_ref = TableReference .from_api_repr (source_config )
13621359 sources .append (table_ref )
@@ -1367,13 +1364,13 @@ def create_job(self, job_config, retry=DEFAULT_RETRY):
13671364 extract_job_config = google .cloud .bigquery .job .ExtractJobConfig .from_api_repr (
13681365 job_config
13691366 )
1370- source = TableReference . from_api_repr (job_config ["extract" ][ "sourceTable" ])
1367+ source = _get_sub_prop (job_config , ["extract" , "sourceTable" ])
13711368 destination_uris = _get_sub_prop (job_config , ["extract" , "destinationUris" ])
13721369 return self .extract_table (
13731370 source , destination_uris , job_config = extract_job_config , retry = retry
13741371 )
13751372 elif "query" in job_config :
1376- del job_config ["query" ][ "destinationTable" ]
1373+ _del_sub_prop ( job_config , ["query" , "destinationTable" ])
13771374 query_job_config = google .cloud .bigquery .job .QueryJobConfig .from_api_repr (
13781375 job_config
13791376 )
0 commit comments