Skip to content

Commit 6c77ada

Browse files
authored
Merge branch 'main' into start-index-2
2 parents 90115a3 + d92b487 commit 6c77ada

36 files changed

+204
-80
lines changed

.github/workflows/docs.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- main
5+
name: docs
6+
jobs:
7+
docs:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
- name: Setup Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.10'
16+
- name: Install nox
17+
run: |
18+
python -m pip install --upgrade setuptools pip wheel
19+
python -m pip install nox
20+
- name: Run docs session
21+
run: |
22+
nox -s docs-3.10
23+
24+
docfx:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.10'
33+
- name: Install nox
34+
run: |
35+
python -m pip install --upgrade setuptools pip wheel
36+
python -m pip install nox
37+
- name: Run docfx session
38+
run: |
39+
nox -s docfx-3.10

.kokoro/presubmit/presubmit.cfg

Lines changed: 0 additions & 7 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@
55
[1]: https://pypi.org/project/google-cloud-bigquery/#history
66

77

8+
## [3.34.0](https://github.com/googleapis/python-bigquery/compare/v3.33.0...v3.34.0) (2025-05-27)
9+
10+
11+
### Features
12+
13+
* Job creation mode GA ([#2190](https://github.com/googleapis/python-bigquery/issues/2190)) ([64cd39f](https://github.com/googleapis/python-bigquery/commit/64cd39fb395c4a03ef6d2ec8261e1709477b2186))
14+
15+
16+
### Bug Fixes
17+
18+
* **deps:** Update all dependencies ([#2184](https://github.com/googleapis/python-bigquery/issues/2184)) ([12490f2](https://github.com/googleapis/python-bigquery/commit/12490f2f03681516465fc34217dcdf57000f6fdd))
19+
20+
21+
### Documentation
22+
23+
* Update query.py ([#2192](https://github.com/googleapis/python-bigquery/issues/2192)) ([9b5ee78](https://github.com/googleapis/python-bigquery/commit/9b5ee78f046d9ca3f758eeca6244b8485fe35875))
24+
* Use query_and_wait in the array parameters sample ([#2202](https://github.com/googleapis/python-bigquery/issues/2202)) ([28a9994](https://github.com/googleapis/python-bigquery/commit/28a9994792ec90a6a4d16835faf2137c09c0fb02))
25+
826
## [3.33.0](https://github.com/googleapis/python-bigquery/compare/v3.32.0...v3.33.0) (2025-05-19)
927

1028

google/cloud/bigquery/_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def range_to_py(self, value, field):
388388

389389

390390
class DataFrameCellDataParser(CellDataParser):
391-
"""Override of CellDataParser to handle differences in expection of values in DataFrame-like outputs.
391+
"""Override of CellDataParser to handle differences in expression of values in DataFrame-like outputs.
392392
393393
This is used to turn the output of the REST API into a pyarrow Table,
394394
emulating the serialized arrow from the BigQuery Storage Read API.

google/cloud/bigquery/_job_helpers.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
import copy
3939
import functools
40-
import os
4140
import uuid
4241
import textwrap
4342
from typing import Any, Dict, Optional, TYPE_CHECKING, Union
@@ -400,12 +399,6 @@ def query_and_wait(
400399
) -> table.RowIterator:
401400
"""Run the query, wait for it to finish, and return the results.
402401
403-
While ``jobCreationMode=JOB_CREATION_OPTIONAL`` is in preview in the
404-
``jobs.query`` REST API, use the default ``jobCreationMode`` unless
405-
the environment variable ``QUERY_PREVIEW_ENABLED=true``. After
406-
``jobCreationMode`` is GA, this method will always use
407-
``jobCreationMode=JOB_CREATION_OPTIONAL``. See:
408-
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query
409402
410403
Args:
411404
client:
@@ -500,9 +493,8 @@ def query_and_wait(
500493
request_body["maxResults"] = min(page_size, max_results)
501494
elif page_size is not None or max_results is not None:
502495
request_body["maxResults"] = page_size or max_results
503-
504-
if os.getenv("QUERY_PREVIEW_ENABLED", "").casefold() == "true":
505-
request_body["jobCreationMode"] = "JOB_CREATION_OPTIONAL"
496+
if client.default_job_creation_mode:
497+
request_body["jobCreationMode"] = client.default_job_creation_mode
506498

507499
def do_query():
508500
request_body["requestId"] = make_job_id()

google/cloud/bigquery/_pandas_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ def determine_requested_streams(
11441144
"""
11451145

11461146
if preserve_order:
1147-
# If preserve order is set, it takes precendence.
1147+
# If preserve order is set, it takes precedence.
11481148
# Limit the requested streams to 1, to ensure that order
11491149
# is preserved)
11501150
return 1

google/cloud/bigquery/client.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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``.
@@ -3539,13 +3554,6 @@ def query_and_wait(
35393554
) -> RowIterator:
35403555
"""Run the query, wait for it to finish, and return the results.
35413556
3542-
While ``jobCreationMode=JOB_CREATION_OPTIONAL`` is in preview in the
3543-
``jobs.query`` REST API, use the default ``jobCreationMode`` unless
3544-
the environment variable ``QUERY_PREVIEW_ENABLED=true``. After
3545-
``jobCreationMode`` is GA, this method will always use
3546-
``jobCreationMode=JOB_CREATION_OPTIONAL``. See:
3547-
https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query
3548-
35493557
Args:
35503558
query (str):
35513559
SQL query to be executed. Defaults to the standard SQL
@@ -4141,7 +4149,7 @@ def _list_rows_from_query_results(
41414149
rows that were affected.
41424150
query (Optional[str]):
41434151
The query text used.
4144-
total_bytes_processed (Optinal[int]):
4152+
total_bytes_processed (Optional[int]):
41454153
total bytes processed from job statistics, if present.
41464154
41474155
Returns:

google/cloud/bigquery/enums.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,3 +407,22 @@ class BigLakeTableFormat(object):
407407

408408
ICEBERG = "ICEBERG"
409409
"""Apache Iceberg format."""
410+
411+
412+
class JobCreationMode(object):
413+
"""Documented values for Job Creation Mode."""
414+
415+
JOB_CREATION_MODE_UNSPECIFIED = "JOB_CREATION_MODE_UNSPECIFIED"
416+
"""Job creation mode is unspecified."""
417+
418+
JOB_CREATION_REQUIRED = "JOB_CREATION_REQUIRED"
419+
"""Job creation is always required."""
420+
421+
JOB_CREATION_OPTIONAL = "JOB_CREATION_OPTIONAL"
422+
"""Job creation is optional.
423+
424+
Returning immediate results is prioritized.
425+
BigQuery will automatically determine if a Job needs to be created.
426+
The conditions under which BigQuery can decide to not create a Job are
427+
subject to change.
428+
"""

google/cloud/bigquery/job/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1534,7 +1534,7 @@ def result( # type: ignore # (incompatible with supertype)
15341534
a DDL query, an ``_EmptyRowIterator`` instance is returned.
15351535
15361536
Raises:
1537-
google.cloud.exceptions.GoogleAPICallError:
1537+
google.api_core.exceptions.GoogleAPICallError:
15381538
If the job failed and retries aren't successful.
15391539
concurrent.futures.TimeoutError:
15401540
If the job did not complete in the given timeout.

google/cloud/bigquery/table.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import geopandas # type: ignore
4545
except ImportError:
4646
geopandas = None
47-
else:
47+
finally:
4848
_COORDINATE_REFERENCE_SYSTEM = "EPSG:4326"
4949

5050
try:
@@ -1786,7 +1786,7 @@ class RowIterator(HTTPIterator):
17861786
the first page is requested.
17871787
query (Optional[str]):
17881788
The query text used.
1789-
total_bytes_processed (Optinal[int]):
1789+
total_bytes_processed (Optional[int]):
17901790
total bytes processed from job statistics, if present.
17911791
"""
17921792

0 commit comments

Comments
 (0)