@@ -210,6 +210,9 @@ class Client(ClientWithProject):
210
210
default_query_job_config (Optional[google.cloud.bigquery.job.QueryJobConfig]):
211
211
Default ``QueryJobConfig``.
212
212
Will be merged into job configs passed into the ``query`` method.
213
+ default_load_job_config (Optional[google.cloud.bigquery.job.LoadJobConfig]):
214
+ Default ``LoadJobConfig``.
215
+ Will be merged into job configs passed into the ``load_table_*`` methods.
213
216
client_info (Optional[google.api_core.client_info.ClientInfo]):
214
217
The client info used to send a user-agent string along with API
215
218
requests. If ``None``, then default info will be used. Generally,
@@ -235,6 +238,7 @@ def __init__(
235
238
_http = None ,
236
239
location = None ,
237
240
default_query_job_config = None ,
241
+ default_load_job_config = None ,
238
242
client_info = None ,
239
243
client_options = None ,
240
244
) -> None :
@@ -260,6 +264,7 @@ def __init__(
260
264
self ._connection = Connection (self , ** kw_args )
261
265
self ._location = location
262
266
self ._default_query_job_config = copy .deepcopy (default_query_job_config )
267
+ self ._default_load_job_config = copy .deepcopy (default_load_job_config )
263
268
264
269
@property
265
270
def location (self ):
@@ -277,6 +282,17 @@ def default_query_job_config(self):
277
282
def default_query_job_config (self , value : QueryJobConfig ):
278
283
self ._default_query_job_config = copy .deepcopy (value )
279
284
285
+ @property
286
+ def default_load_job_config (self ):
287
+ """Default ``LoadJobConfig``.
288
+ Will be merged into job configs passed into the ``load_table_*`` methods.
289
+ """
290
+ return self ._default_load_job_config
291
+
292
+ @default_load_job_config .setter
293
+ def default_load_job_config (self , value : LoadJobConfig ):
294
+ self ._default_load_job_config = copy .deepcopy (value )
295
+
280
296
def close (self ):
281
297
"""Close the underlying transport objects, releasing system resources.
282
298
@@ -2348,9 +2364,19 @@ def load_table_from_uri(
2348
2364
2349
2365
destination = _table_arg_to_table_ref (destination , default_project = self .project )
2350
2366
2367
+ # Make a copy so that the job config isn't modified in-place.
2351
2368
if job_config :
2352
- job_config = copy .deepcopy (job_config )
2353
2369
_verify_job_config_type (job_config , google .cloud .bigquery .job .LoadJobConfig )
2370
+ job_config = copy .deepcopy (job_config )
2371
+ else :
2372
+ job_config = job .LoadJobConfig ()
2373
+
2374
+ # Merge this job config with a default job config
2375
+ if self ._default_load_job_config :
2376
+ _verify_job_config_type (
2377
+ self ._default_load_job_config , google .cloud .bigquery .job .LoadJobConfig
2378
+ )
2379
+ job_config = job_config ._fill_from_default (self ._default_load_job_config )
2354
2380
2355
2381
load_job = job .LoadJob (job_ref , source_uris , destination , self , job_config )
2356
2382
load_job ._begin (retry = retry , timeout = timeout )
@@ -2437,9 +2463,21 @@ def load_table_from_file(
2437
2463
2438
2464
destination = _table_arg_to_table_ref (destination , default_project = self .project )
2439
2465
job_ref = job ._JobReference (job_id , project = project , location = location )
2466
+
2467
+ # Make a copy so that the job config isn't modified in-place.
2440
2468
if job_config :
2441
- job_config = copy .deepcopy (job_config )
2442
2469
_verify_job_config_type (job_config , google .cloud .bigquery .job .LoadJobConfig )
2470
+ job_config = copy .deepcopy (job_config )
2471
+ else :
2472
+ job_config = job .LoadJobConfig ()
2473
+
2474
+ # Merge this job config with a default job config
2475
+ if self ._default_load_job_config :
2476
+ _verify_job_config_type (
2477
+ self ._default_load_job_config , google .cloud .bigquery .job .LoadJobConfig
2478
+ )
2479
+ job_config = job_config ._fill_from_default (self ._default_load_job_config )
2480
+
2443
2481
load_job = job .LoadJob (job_ref , None , destination , self , job_config )
2444
2482
job_resource = load_job .to_api_repr ()
2445
2483
@@ -2569,13 +2607,10 @@ def load_table_from_dataframe(
2569
2607
"""
2570
2608
job_id = _make_job_id (job_id , job_id_prefix )
2571
2609
2610
+ # Make a copy so that the job config isn't modified in-place.
2572
2611
if job_config :
2573
2612
_verify_job_config_type (job_config , google .cloud .bigquery .job .LoadJobConfig )
2574
- # Make a copy so that the job config isn't modified in-place.
2575
- job_config_properties = copy .deepcopy (job_config ._properties )
2576
- job_config = job .LoadJobConfig ()
2577
- job_config ._properties = job_config_properties
2578
-
2613
+ job_config = copy .deepcopy (job_config )
2579
2614
else :
2580
2615
job_config = job .LoadJobConfig ()
2581
2616
0 commit comments