18
18
import copy
19
19
import re
20
20
import typing
21
- from typing import Any , Dict , List , Optional , Union
21
+ from typing import Any , Dict , Iterable , List , Optional , Union
22
22
23
23
from google .api_core import exceptions
24
24
from google .api_core .future import polling as polling_future
31
31
from google .cloud .bigquery .enums import KeyResultStatementKind
32
32
from google .cloud .bigquery .external_config import ExternalConfig
33
33
from google .cloud .bigquery import _helpers
34
- from google .cloud .bigquery .query import _query_param_from_api_repr
35
- from google .cloud .bigquery .query import ArrayQueryParameter
36
- from google .cloud .bigquery .query import ScalarQueryParameter
37
- from google .cloud .bigquery .query import StructQueryParameter
38
- from google .cloud .bigquery .query import UDFResource
34
+ from google .cloud .bigquery .query import (
35
+ _query_param_from_api_repr ,
36
+ ArrayQueryParameter ,
37
+ ConnectionProperty ,
38
+ ScalarQueryParameter ,
39
+ StructQueryParameter ,
40
+ UDFResource ,
41
+ )
39
42
from google .cloud .bigquery .retry import DEFAULT_RETRY , DEFAULT_JOB_RETRY
40
43
from google .cloud .bigquery .routine import RoutineReference
41
44
from google .cloud .bigquery .schema import SchemaField
@@ -269,6 +272,24 @@ def allow_large_results(self):
269
272
def allow_large_results (self , value ):
270
273
self ._set_sub_prop ("allowLargeResults" , value )
271
274
275
+ @property
276
+ def connection_properties (self ) -> List [ConnectionProperty ]:
277
+ """Connection properties.
278
+
279
+ See
280
+ https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.connection_properties
281
+
282
+ .. versionadded:: 2.29.0
283
+ """
284
+ resource = self ._get_sub_prop ("connectionProperties" , [])
285
+ return [ConnectionProperty .from_api_repr (prop ) for prop in resource ]
286
+
287
+ @connection_properties .setter
288
+ def connection_properties (self , value : Iterable [ConnectionProperty ]):
289
+ self ._set_sub_prop (
290
+ "connectionProperties" , [prop .to_api_repr () for prop in value ],
291
+ )
292
+
272
293
@property
273
294
def create_disposition (self ):
274
295
"""google.cloud.bigquery.job.CreateDisposition: Specifies behavior
@@ -283,6 +304,27 @@ def create_disposition(self):
283
304
def create_disposition (self , value ):
284
305
self ._set_sub_prop ("createDisposition" , value )
285
306
307
+ @property
308
+ def create_session (self ) -> Optional [bool ]:
309
+ """[Preview] If :data:`True`, creates a new session, where
310
+ :attr:`~google.cloud.bigquery.job.QueryJob.session_info` will contain a
311
+ random server generated session id.
312
+
313
+ If :data:`False`, runs query with an existing ``session_id`` passed in
314
+ :attr:`~google.cloud.bigquery.job.QueryJobConfig.connection_properties`,
315
+ otherwise runs query in non-session mode.
316
+
317
+ See
318
+ https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationQuery.FIELDS.create_session
319
+
320
+ .. versionadded:: 2.29.0
321
+ """
322
+ return self ._get_sub_prop ("createSession" )
323
+
324
+ @create_session .setter
325
+ def create_session (self , value : Optional [bool ]):
326
+ self ._set_sub_prop ("createSession" , value )
327
+
286
328
@property
287
329
def default_dataset (self ):
288
330
"""google.cloud.bigquery.dataset.DatasetReference: the default dataset
@@ -613,7 +655,7 @@ def schema_update_options(self, values):
613
655
614
656
@property
615
657
def script_options (self ) -> ScriptOptions :
616
- """Connection properties which can modify the query behavior .
658
+ """Options controlling the execution of scripts .
617
659
618
660
https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#scriptoptions
619
661
"""
@@ -694,13 +736,31 @@ def allow_large_results(self):
694
736
"""
695
737
return self ._configuration .allow_large_results
696
738
739
+ @property
740
+ def connection_properties (self ) -> List [ConnectionProperty ]:
741
+ """See
742
+ :attr:`google.cloud.bigquery.job.QueryJobConfig.connection_properties`.
743
+
744
+ .. versionadded:: 2.29.0
745
+ """
746
+ return self ._configuration .connection_properties
747
+
697
748
@property
698
749
def create_disposition (self ):
699
750
"""See
700
751
:attr:`google.cloud.bigquery.job.QueryJobConfig.create_disposition`.
701
752
"""
702
753
return self ._configuration .create_disposition
703
754
755
+ @property
756
+ def create_session (self ) -> Optional [bool ]:
757
+ """See
758
+ :attr:`google.cloud.bigquery.job.QueryJobConfig.create_session`.
759
+
760
+ .. versionadded:: 2.29.0
761
+ """
762
+ return self ._configuration .create_session
763
+
704
764
@property
705
765
def default_dataset (self ):
706
766
"""See
0 commit comments