9090from google .cloud .bigquery .dataset import Dataset
9191from google .cloud .bigquery .dataset import DatasetListItem
9292from google .cloud .bigquery .dataset import DatasetReference
93- from google .cloud .bigquery .enums import AutoRowIDs
93+
94+ from google .cloud .bigquery .enums import AutoRowIDs , DatasetView , UpdateMode
9495from google .cloud .bigquery .format_options import ParquetOptions
9596from google .cloud .bigquery .job import (
9697 CopyJob ,
@@ -221,6 +222,10 @@ class Client(ClientWithProject):
221222 client_options (Optional[Union[google.api_core.client_options.ClientOptions, Dict]]):
222223 Client options used to set user options on the client. API Endpoint
223224 should be set through client_options.
225+ default_job_creation_mode (Optional[str]):
226+ Sets the default job creation mode used by query methods such as
227+ query_and_wait(). For lightweight queries, JOB_CREATION_OPTIONAL is
228+ generally recommended.
224229
225230 Raises:
226231 google.auth.exceptions.DefaultCredentialsError:
@@ -243,6 +248,7 @@ def __init__(
243248 client_options : Optional [
244249 Union [google .api_core .client_options .ClientOptions , Dict [str , Any ]]
245250 ] = None ,
251+ default_job_creation_mode : Optional [str ] = None ,
246252 ) -> None :
247253 if client_options is None :
248254 client_options = {}
@@ -277,6 +283,7 @@ def __init__(
277283 self ._connection = Connection (self , ** kw_args )
278284 self ._location = location
279285 self ._default_load_job_config = copy .deepcopy (default_load_job_config )
286+ self .default_job_creation_mode = default_job_creation_mode
280287
281288 # Use property setter so validation can run.
282289 self .default_query_job_config = default_query_job_config
@@ -286,6 +293,15 @@ def location(self):
286293 """Default location for jobs / datasets / tables."""
287294 return self ._location
288295
296+ @property
297+ def default_job_creation_mode (self ):
298+ """Default job creation mode used for query execution."""
299+ return self ._default_job_creation_mode
300+
301+ @default_job_creation_mode .setter
302+ def default_job_creation_mode (self , value : Optional [str ]):
303+ self ._default_job_creation_mode = value
304+
289305 @property
290306 def default_query_job_config (self ) -> Optional [QueryJobConfig ]:
291307 """Default ``QueryJobConfig`` or ``None``.
@@ -849,6 +865,7 @@ def get_dataset(
849865 dataset_ref : Union [DatasetReference , str ],
850866 retry : retries .Retry = DEFAULT_RETRY ,
851867 timeout : TimeoutType = DEFAULT_TIMEOUT ,
868+ dataset_view : Optional [DatasetView ] = None ,
852869 ) -> Dataset :
853870 """Fetch the dataset referenced by ``dataset_ref``
854871
@@ -866,7 +883,21 @@ def get_dataset(
866883 timeout (Optional[float]):
867884 The number of seconds to wait for the underlying HTTP transport
868885 before using ``retry``.
869-
886+ dataset_view (Optional[google.cloud.bigquery.enums.DatasetView]):
887+ Specifies the view that determines which dataset information is
888+ returned. By default, dataset metadata (e.g. friendlyName, description,
889+ labels, etc) and ACL information are returned. This argument can
890+ take on the following possible enum values.
891+
892+ * :attr:`~google.cloud.bigquery.enums.DatasetView.ACL`:
893+ Includes dataset metadata and the ACL.
894+ * :attr:`~google.cloud.bigquery.enums.DatasetView.FULL`:
895+ Includes all dataset metadata, including the ACL and table metadata.
896+ This view is not supported by the `datasets.list` API method.
897+ * :attr:`~google.cloud.bigquery.enums.DatasetView.METADATA`:
898+ Includes basic dataset metadata, but not the ACL.
899+ * :attr:`~google.cloud.bigquery.enums.DatasetView.DATASET_VIEW_UNSPECIFIED`:
900+ The server will decide which view to use. Currently defaults to FULL.
870901 Returns:
871902 google.cloud.bigquery.dataset.Dataset:
872903 A ``Dataset`` instance.
@@ -876,6 +907,12 @@ def get_dataset(
876907 dataset_ref , default_project = self .project
877908 )
878909 path = dataset_ref .path
910+
911+ if dataset_view :
912+ query_params = {"datasetView" : dataset_view .value }
913+ else :
914+ query_params = {}
915+
879916 span_attributes = {"path" : path }
880917 api_response = self ._call_api (
881918 retry ,
@@ -884,6 +921,7 @@ def get_dataset(
884921 method = "GET" ,
885922 path = path ,
886923 timeout = timeout ,
924+ query_params = query_params ,
887925 )
888926 return Dataset .from_api_repr (api_response )
889927
@@ -1183,6 +1221,7 @@ def update_dataset(
11831221 fields : Sequence [str ],
11841222 retry : retries .Retry = DEFAULT_RETRY ,
11851223 timeout : TimeoutType = DEFAULT_TIMEOUT ,
1224+ update_mode : Optional [UpdateMode ] = None ,
11861225 ) -> Dataset :
11871226 """Change some fields of a dataset.
11881227
@@ -1222,6 +1261,20 @@ def update_dataset(
12221261 timeout (Optional[float]):
12231262 The number of seconds to wait for the underlying HTTP transport
12241263 before using ``retry``.
1264+ update_mode (Optional[google.cloud.bigquery.enums.UpdateMode]):
1265+ Specifies the kind of information to update in a dataset.
1266+ By default, dataset metadata (e.g. friendlyName, description,
1267+ labels, etc) and ACL information are updated. This argument can
1268+ take on the following possible enum values.
1269+
1270+ * :attr:`~google.cloud.bigquery.enums.UPDATE_MODE_UNSPECIFIED`:
1271+ The default value. Behavior defaults to UPDATE_FULL.
1272+ * :attr:`~google.cloud.bigquery.enums.UpdateMode.UPDATE_METADATA`:
1273+ Includes metadata information for the dataset, such as friendlyName, description, labels, etc.
1274+ * :attr:`~google.cloud.bigquery.enums.UpdateMode.UPDATE_ACL`:
1275+ Includes ACL information for the dataset, which defines dataset access for one or more entities.
1276+ * :attr:`~google.cloud.bigquery.enums.UpdateMode.UPDATE_FULL`:
1277+ Includes both dataset metadata and ACL information.
12251278
12261279 Returns:
12271280 google.cloud.bigquery.dataset.Dataset:
@@ -1235,6 +1288,11 @@ def update_dataset(
12351288 path = dataset .path
12361289 span_attributes = {"path" : path , "fields" : fields }
12371290
1291+ if update_mode :
1292+ query_params = {"updateMode" : update_mode .value }
1293+ else :
1294+ query_params = {}
1295+
12381296 api_response = self ._call_api (
12391297 retry ,
12401298 span_name = "BigQuery.updateDataset" ,
@@ -1244,6 +1302,7 @@ def update_dataset(
12441302 data = partial ,
12451303 headers = headers ,
12461304 timeout = timeout ,
1305+ query_params = query_params ,
12471306 )
12481307 return Dataset .from_api_repr (api_response )
12491308
@@ -1986,6 +2045,7 @@ def _get_query_results(
19862045 location : Optional [str ] = None ,
19872046 timeout : TimeoutType = DEFAULT_TIMEOUT ,
19882047 page_size : int = 0 ,
2048+ start_index : Optional [int ] = None ,
19892049 ) -> _QueryResults :
19902050 """Get the query results object for a query job.
19912051
@@ -2004,9 +2064,12 @@ def _get_query_results(
20042064 before using ``retry``. If set, this connection timeout may be
20052065 increased to a minimum value. This prevents retries on what
20062066 would otherwise be a successful response.
2007- page_size (int):
2067+ page_size (Optional[ int] ):
20082068 Maximum number of rows in a single response. See maxResults in
20092069 the jobs.getQueryResults REST API.
2070+ start_index (Optional[int]):
2071+ Zero-based index of the starting row. See startIndex in the
2072+ jobs.getQueryResults REST API.
20102073
20112074 Returns:
20122075 google.cloud.bigquery.query._QueryResults:
@@ -2036,6 +2099,9 @@ def _get_query_results(
20362099 if location is not None :
20372100 extra_params ["location" ] = location
20382101
2102+ if start_index is not None :
2103+ extra_params ["startIndex" ] = start_index
2104+
20392105 path = "/projects/{}/queries/{}" .format (project , job_id )
20402106
20412107 # This call is typically made in a polling loop that checks whether the
@@ -3532,13 +3598,6 @@ def query_and_wait(
35323598 ) -> RowIterator :
35333599 """Run the query, wait for it to finish, and return the results.
35343600
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-
35423601 Args:
35433602 query (str):
35443603 SQL query to be executed. Defaults to the standard SQL
0 commit comments