1818import copy
1919import re
2020import typing
21- from typing import Any , Dict , List , Optional , Union
21+ from typing import Any , Dict , Iterable , List , Optional , Union
2222
2323from google .api_core import exceptions
2424from google .api_core .future import polling as polling_future
3131from google .cloud .bigquery .enums import KeyResultStatementKind
3232from google .cloud .bigquery .external_config import ExternalConfig
3333from 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+ )
3942from google .cloud .bigquery .retry import DEFAULT_RETRY , DEFAULT_JOB_RETRY
4043from google .cloud .bigquery .routine import RoutineReference
4144from google .cloud .bigquery .schema import SchemaField
@@ -269,6 +272,24 @@ def allow_large_results(self):
269272 def allow_large_results (self , value ):
270273 self ._set_sub_prop ("allowLargeResults" , value )
271274
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+
272293 @property
273294 def create_disposition (self ):
274295 """google.cloud.bigquery.job.CreateDisposition: Specifies behavior
@@ -283,6 +304,27 @@ def create_disposition(self):
283304 def create_disposition (self , value ):
284305 self ._set_sub_prop ("createDisposition" , value )
285306
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+
286328 @property
287329 def default_dataset (self ):
288330 """google.cloud.bigquery.dataset.DatasetReference: the default dataset
@@ -613,7 +655,7 @@ def schema_update_options(self, values):
613655
614656 @property
615657 def script_options (self ) -> ScriptOptions :
616- """Connection properties which can modify the query behavior .
658+ """Options controlling the execution of scripts .
617659
618660 https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#scriptoptions
619661 """
@@ -694,13 +736,31 @@ def allow_large_results(self):
694736 """
695737 return self ._configuration .allow_large_results
696738
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+
697748 @property
698749 def create_disposition (self ):
699750 """See
700751 :attr:`google.cloud.bigquery.job.QueryJobConfig.create_disposition`.
701752 """
702753 return self ._configuration .create_disposition
703754
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+
704764 @property
705765 def default_dataset (self ):
706766 """See
0 commit comments