Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: sync main into v3 branch #1109

Merged
merged 17 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/.OwlBot.lock.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
digest: sha256:2f90537dd7df70f6b663cd654b1fa5dee483cf6a4edcfd46072b2775be8a23ec
digest: sha256:f0e4b51deef56bed74d3e2359c583fc104a8d6367da3984fc5c66938db738828
1 change: 1 addition & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
releaseType: python
handleGHRelease: true
1 change: 1 addition & 0 deletions .github/release-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enabled: true
2 changes: 1 addition & 1 deletion .kokoro/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools
export PYTHONUNBUFFERED=1

# Move into the package, build the distribution and upload.
TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token")
TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1")
cd github/python-bigquery
python3 setup.py sdist bdist_wheel
twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*
12 changes: 11 additions & 1 deletion .kokoro/release/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,18 @@ env_vars: {
value: "github/python-bigquery/.kokoro/release.sh"
}

# Fetch PyPI password
before_action {
fetch_keystore {
keystore_resource {
keystore_config_id: 73713
keyname: "google-cloud-pypi-token-keystore-1"
}
}
}

# Tokens needed to report release status back to GitHub
env_vars: {
key: "SECRET_MANAGER_KEYS"
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token"
value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
}
7 changes: 4 additions & 3 deletions .repo-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "bigquery",
"name_pretty": "Google Cloud BigQuery",
"product_documentation": "https://cloud.google.com/bigquery",
"client_documentation": "https://googleapis.dev/python/bigquery/latest",
"client_documentation": "https://cloud.google.com/python/docs/reference/bigquery/latest",
"issue_tracker": "https://issuetracker.google.com/savedsearches/559654",
"release_level": "ga",
"release_level": "stable",
"language": "python",
"library_type": "GAPIC_COMBO",
"repo": "googleapis/python-bigquery",
"distribution_name": "google-cloud-bigquery",
"api_id": "bigquery.googleapis.com",
"requires_billing": false,
"default_version": "v2",
"codeowner_team": "@googleapis/api-bigquery"
"codeowner_team": "@googleapis/api-bigquery",
"api_shortname": "bigquery"
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
[1]: https://pypi.org/project/google-cloud-bigquery/#history


## [2.32.0](https://github.com/googleapis/python-bigquery/compare/v2.31.0...v2.32.0) (2022-01-12)


### Features

* support authorized dataset entity ([#1075](https://github.com/googleapis/python-bigquery/issues/1075)) ([c098cd0](https://github.com/googleapis/python-bigquery/commit/c098cd01c755633bfaba7193dd5c044a489a5b61))


### Bug Fixes

* remove query text from exception message, use `exception.debug_message` instead ([#1105](https://github.com/googleapis/python-bigquery/issues/1105)) ([e23114c](https://github.com/googleapis/python-bigquery/commit/e23114ce362e09ac72f733a640e53a561cc9ce69))

## [2.31.0](https://www.github.com/googleapis/python-bigquery/compare/v2.30.1...v2.31.0) (2021-11-24)


Expand Down
7 changes: 2 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Python Client for Google BigQuery
=================================

|GA| |pypi| |versions|
|GA| |pypi| |versions|

Querying massive datasets can be time consuming and expensive without the
right hardware and infrastructure. Google `BigQuery`_ solves this problem by
Expand Down Expand Up @@ -52,7 +52,7 @@ dependencies.

Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.6, < 3.10
Python >= 3.6, < 3.11

Unsupported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -140,6 +140,3 @@ In this example all tracing data will be published to the Google

.. _OpenTelemetry documentation: https://opentelemetry-python.readthedocs.io
.. _Cloud Trace: https://cloud.google.com/trace



19 changes: 13 additions & 6 deletions google/cloud/bigquery/job/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@


_CONTAINS_ORDER_BY = re.compile(r"ORDER\s+BY", re.IGNORECASE)
_EXCEPTION_FOOTER_TEMPLATE = "{message}\n\nLocation: {location}\nJob ID: {job_id}\n"
_TIMEOUT_BUFFER_SECS = 0.1


Expand Down Expand Up @@ -1196,17 +1197,17 @@ def _blocking_poll(self, timeout=None, **kwargs):
super(QueryJob, self)._blocking_poll(timeout=timeout, **kwargs)

@staticmethod
def _format_for_exception(query, job_id):
def _format_for_exception(message: str, query: str):
"""Format a query for the output in exception message.

Args:
message (str): The original exception message.
query (str): The SQL query to format.
job_id (str): The ID of the job that ran the query.

Returns:
str: A formatted query text.
"""
template = "\n\n(job ID: {job_id})\n\n{header}\n\n{ruler}\n{body}\n{ruler}"
template = "{message}\n\n{header}\n\n{ruler}\n{body}\n{ruler}"

lines = query.splitlines()
max_line_len = max(len(line) for line in lines)
Expand All @@ -1223,7 +1224,7 @@ def _format_for_exception(query, job_id):
"{:4}:{}".format(n, line) for n, line in enumerate(lines, start=1)
)

return template.format(job_id=job_id, header=header, ruler=ruler, body=body)
return template.format(message=message, header=header, ruler=ruler, body=body)

def _begin(self, client=None, retry=DEFAULT_RETRY, timeout=None):
"""API call: begin the job via a POST request
Expand All @@ -1248,7 +1249,10 @@ def _begin(self, client=None, retry=DEFAULT_RETRY, timeout=None):
try:
super(QueryJob, self)._begin(client=client, retry=retry, timeout=timeout)
except exceptions.GoogleAPICallError as exc:
exc.message += self._format_for_exception(self.query, self.job_id)
exc.message = _EXCEPTION_FOOTER_TEMPLATE.format(
message=exc.message, location=self.location, job_id=self.job_id
)
exc.debug_message = self._format_for_exception(exc.message, self.query)
exc.query_job = self
raise

Expand Down Expand Up @@ -1447,7 +1451,10 @@ def do_get_result():
do_get_result()

except exceptions.GoogleAPICallError as exc:
exc.message += self._format_for_exception(self.query, self.job_id)
exc.message = _EXCEPTION_FOOTER_TEMPLATE.format(
message=exc.message, location=self.location, job_id=self.job_id
)
exc.debug_message = self._format_for_exception(exc.message, self.query) # type: ignore
exc.query_job = self # type: ignore
raise
except requests.exceptions.Timeout as exc:
Expand Down
71 changes: 40 additions & 31 deletions samples/geography/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from __future__ import print_function

import glob
import os
from pathlib import Path
import sys
Expand Down Expand Up @@ -184,37 +185,45 @@ def blacken(session: nox.sessions.Session) -> None:
def _session_tests(
session: nox.sessions.Session, post_install: Callable = None
) -> None:
if TEST_CONFIG["pip_version_override"]:
pip_version = TEST_CONFIG["pip_version_override"]
session.install(f"pip=={pip_version}")
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
if os.path.exists("constraints.txt"):
session.install("-r", "requirements.txt", "-c", "constraints.txt")
else:
session.install("-r", "requirements.txt")

if os.path.exists("requirements-test.txt"):
if os.path.exists("constraints-test.txt"):
session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
else:
session.install("-r", "requirements-test.txt")

if INSTALL_LIBRARY_FROM_SOURCE:
session.install("-e", _get_repo_root())

if post_install:
post_install(session)

session.run(
"pytest",
*(PYTEST_COMMON_ARGS + session.posargs),
# Pytest will return 5 when no tests are collected. This can happen
# on travis where slow and flaky tests are excluded.
# See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
success_codes=[0, 5],
env=get_pytest_env_vars(),
)
# check for presence of tests
test_list = glob.glob("*_test.py") + glob.glob("test_*.py")
test_list.extend(glob.glob("tests"))
if len(test_list) == 0:
print("No tests found, skipping directory.")
else:
if TEST_CONFIG["pip_version_override"]:
pip_version = TEST_CONFIG["pip_version_override"]
session.install(f"pip=={pip_version}")
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
if os.path.exists("constraints.txt"):
session.install("-r", "requirements.txt", "-c", "constraints.txt")
else:
session.install("-r", "requirements.txt")

if os.path.exists("requirements-test.txt"):
if os.path.exists("constraints-test.txt"):
session.install(
"-r", "requirements-test.txt", "-c", "constraints-test.txt"
)
else:
session.install("-r", "requirements-test.txt")

if INSTALL_LIBRARY_FROM_SOURCE:
session.install("-e", _get_repo_root())

if post_install:
post_install(session)

session.run(
"pytest",
*(PYTEST_COMMON_ARGS + session.posargs),
# Pytest will return 5 when no tests are collected. This can happen
# on travis where slow and flaky tests are excluded.
# See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
success_codes=[0, 5],
env=get_pytest_env_vars(),
)


@nox.session(python=ALL_VERSIONS)
Expand Down
27 changes: 11 additions & 16 deletions samples/geography/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,46 @@
attrs==21.2.0
cachetools==4.2.4
attrs==21.4.0
certifi==2021.10.8
cffi==1.15.0
charset-normalizer==2.0.9
charset-normalizer==2.0.10
click==8.0.3
click-plugins==1.1.1
cligj==0.7.2
dataclasses==0.6; python_version < '3.7'
db-dtypes==0.3.0
dataclasses==0.8; python_version < '3.7'
db-dtypes==0.3.1
Fiona==1.8.20
geojson==2.5.0
geopandas==0.9.0; python_version < '3.7'
geopandas==0.10.2; python_version >= '3.7'
google-api-core==2.3.0
google-api-core==2.4.0
google-auth==2.3.3
google-cloud-bigquery==2.31.0
google-cloud-bigquery-storage==2.10.1
google-cloud-core==2.2.1
google-crc32c==1.3.0
google-resumable-media==2.1.0
googleapis-common-protos==1.54.0
grpcio==1.42.0
grpcio==1.43.0
idna==3.3
importlib-metadata==4.8.2
libcst==0.3.23
libcst==0.4.0
munch==2.5.0
mypy-extensions==0.4.3
packaging==21.3
pandas==1.1.5; python_version < '3.7'
pandas==1.3.4; python_version >= '3.7'
pandas==1.3.5; python_version >= '3.7'
proto-plus==1.19.8
protobuf==3.19.1
protobuf==3.19.3
pyarrow==6.0.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pyparsing==3.0.6
pyproj==3.0.1; python_version < "3.7"
pyproj==3.1.0; python_version > "3.6"
python-dateutil==2.8.2
pytz==2021.3
PyYAML==6.0
requests==2.26.0
requests==2.27.1
rsa==4.8
Shapely==1.8.0
six==1.16.0
typing-extensions==4.0.1
typing-inspect==0.7.1
urllib3==1.26.7
zipp==3.6.0
urllib3==1.26.8
71 changes: 40 additions & 31 deletions samples/magics/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from __future__ import print_function

import glob
import os
from pathlib import Path
import sys
Expand Down Expand Up @@ -184,37 +185,45 @@ def blacken(session: nox.sessions.Session) -> None:
def _session_tests(
session: nox.sessions.Session, post_install: Callable = None
) -> None:
if TEST_CONFIG["pip_version_override"]:
pip_version = TEST_CONFIG["pip_version_override"]
session.install(f"pip=={pip_version}")
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
if os.path.exists("constraints.txt"):
session.install("-r", "requirements.txt", "-c", "constraints.txt")
else:
session.install("-r", "requirements.txt")

if os.path.exists("requirements-test.txt"):
if os.path.exists("constraints-test.txt"):
session.install("-r", "requirements-test.txt", "-c", "constraints-test.txt")
else:
session.install("-r", "requirements-test.txt")

if INSTALL_LIBRARY_FROM_SOURCE:
session.install("-e", _get_repo_root())

if post_install:
post_install(session)

session.run(
"pytest",
*(PYTEST_COMMON_ARGS + session.posargs),
# Pytest will return 5 when no tests are collected. This can happen
# on travis where slow and flaky tests are excluded.
# See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
success_codes=[0, 5],
env=get_pytest_env_vars(),
)
# check for presence of tests
test_list = glob.glob("*_test.py") + glob.glob("test_*.py")
test_list.extend(glob.glob("tests"))
if len(test_list) == 0:
print("No tests found, skipping directory.")
else:
if TEST_CONFIG["pip_version_override"]:
pip_version = TEST_CONFIG["pip_version_override"]
session.install(f"pip=={pip_version}")
"""Runs py.test for a particular project."""
if os.path.exists("requirements.txt"):
if os.path.exists("constraints.txt"):
session.install("-r", "requirements.txt", "-c", "constraints.txt")
else:
session.install("-r", "requirements.txt")

if os.path.exists("requirements-test.txt"):
if os.path.exists("constraints-test.txt"):
session.install(
"-r", "requirements-test.txt", "-c", "constraints-test.txt"
)
else:
session.install("-r", "requirements-test.txt")

if INSTALL_LIBRARY_FROM_SOURCE:
session.install("-e", _get_repo_root())

if post_install:
post_install(session)

session.run(
"pytest",
*(PYTEST_COMMON_ARGS + session.posargs),
# Pytest will return 5 when no tests are collected. This can happen
# on travis where slow and flaky tests are excluded.
# See http://doc.pytest.org/en/latest/_modules/_pytest/main.html
success_codes=[0, 5],
env=get_pytest_env_vars(),
)


@nox.session(python=ALL_VERSIONS)
Expand Down
Loading