@@ -221,6 +221,10 @@ class Client(ClientWithProject):
221221 client_options (Optional[Union[google.api_core.client_options.ClientOptions, Dict]]):
222222 Client options used to set user options on the client. API Endpoint
223223 should be set through client_options.
224+ default_job_creation_mode (Optional[str]):
225+ Sets the default job creation mode used by query methods such as
226+ query_and_wait(). For lightweight queries, JOB_CREATION_OPTIONAL is
227+ generally recommended.
224228
225229 Raises:
226230 google.auth.exceptions.DefaultCredentialsError:
@@ -243,6 +247,7 @@ def __init__(
243247 client_options : Optional [
244248 Union [google .api_core .client_options .ClientOptions , Dict [str , Any ]]
245249 ] = None ,
250+ default_job_creation_mode : Optional [str ] = None ,
246251 ) -> None :
247252 if client_options is None :
248253 client_options = {}
@@ -277,6 +282,7 @@ def __init__(
277282 self ._connection = Connection (self , ** kw_args )
278283 self ._location = location
279284 self ._default_load_job_config = copy .deepcopy (default_load_job_config )
285+ self .default_job_creation_mode = default_job_creation_mode
280286
281287 # Use property setter so validation can run.
282288 self .default_query_job_config = default_query_job_config
@@ -286,6 +292,15 @@ def location(self):
286292 """Default location for jobs / datasets / tables."""
287293 return self ._location
288294
295+ @property
296+ def default_job_creation_mode (self ):
297+ """Default job creation mode used for query execution."""
298+ return self ._default_job_creation_mode
299+
300+ @default_job_creation_mode .setter
301+ def default_job_creation_mode (self , value : Optional [str ]):
302+ self ._default_job_creation_mode = value
303+
289304 @property
290305 def default_query_job_config (self ) -> Optional [QueryJobConfig ]:
291306 """Default ``QueryJobConfig`` or ``None``.
@@ -3532,13 +3547,6 @@ def query_and_wait(
35323547 ) -> RowIterator :
35333548 """Run the query, wait for it to finish, and return the results.
35343549
3535- While ``jobCreationMode=JOB_CREATION_OPTIONAL`` is in preview in the
3536- ``jobs.query`` REST API, use the default ``jobCreationMode`` unless
3537- the environment variable ``QUERY_PREVIEW_ENABLED=true``. After
3538- ``jobCreationMode`` is GA, this method will always use
3539- ``jobCreationMode=JOB_CREATION_OPTIONAL``. See:
3540- https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query
3541-
35423550 Args:
35433551 query (str):
35443552 SQL query to be executed. Defaults to the standard SQL
0 commit comments