Skip to content
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3b70891
chore: protect v3.x.x branch (#816)
tswast Jul 27, 2021
3c1be14
fix: no longer raise a warning in `to_dataframe` if `max_results` set…
plamut Jul 27, 2021
fe7a902
feat: Update proto definitions for bigquery/v2 to support new proto f…
gcf-owl-bot[bot] Jul 27, 2021
02bbdae
chore: release 2.23.0 (#819)
release-please[bot] Jul 27, 2021
42b66d3
chore(deps): update dependency google-cloud-bigquery to v2.23.0 (#820)
renovate-bot Jul 28, 2021
d9378af
fix: `insert_rows()` accepts float column values as strings again (#824)
plamut Jul 28, 2021
a505440
chore: release 2.23.1 (#825)
release-please[bot] Jul 28, 2021
c541c69
chore: add second protection rule for v3 branch (#828)
tswast Jul 28, 2021
48e8a35
chore(deps): update dependency google-cloud-bigquery to v2.23.1 (#827)
renovate-bot Jul 28, 2021
d8c25ac
test: retry getting rows after streaming them in `test_insert_rows_fr…
tswast Jul 29, 2021
8149d9e
chore(deps): update dependency pyarrow to v5 (#834)
renovate-bot Jul 29, 2021
b9349ad
chore(deps): update dependency google-cloud-bigquery-storage to v2.6.…
renovate-bot Jul 29, 2021
80e3a61
deps: expand pyarrow pins to support 5.x releases (#833)
plamut Jul 29, 2021
40ef77f
chore: release 2.23.2 (#835)
release-please[bot] Jul 29, 2021
55687b8
chore(deps): update dependency google-auth-oauthlib to v0.4.5 (#839)
renovate-bot Jul 29, 2021
85ce81c
chore(deps): update dependency google-cloud-bigquery to v2.23.2 (#838)
renovate-bot Jul 29, 2021
20df24b
chore(deps): update dependency google-cloud-testutils to v1 (#845)
renovate-bot Aug 3, 2021
7016f69
chore: require CODEOWNER review and up to date branches (#846)
busunkim96 Aug 3, 2021
cf0b0d8
chore: add api-bigquery as a samples owner (#852)
busunkim96 Aug 5, 2021
30770fd
fix: increase default retry deadline to 10 minutes (#859)
tswast Aug 6, 2021
e2cbcaa
process: add yoshi-python to samples CODEOWNERS (#858)
plamut Aug 6, 2021
9694a4d
chore: release 2.23.3 (#860)
release-please[bot] Aug 9, 2021
9c6614f
chore(deps): update dependency google-cloud-bigquery to v2.23.3 (#866)
renovate-bot Aug 9, 2021
7f7b1a8
feat: add support for transaction statistics (#849)
plamut Aug 10, 2021
443b8ab
chore(deps): update dependency google-cloud-bigquery-storage to v2.6.…
renovate-bot Aug 10, 2021
aee814c
chore: fix INSTALL_LIBRARY_FROM_SOURCE in noxfile.py (#869)
gcf-owl-bot[bot] Aug 11, 2021
c1a3d44
feat: make the same `Table*` instances equal to each other (#867)
plamut Aug 11, 2021
93d15e2
feat: support `ScalarQueryParameterType` for `type_` argument in `Sca…
tswast Aug 11, 2021
75d54e6
Merge remote-tracking branch 'upstream/master' into v3-sync
tswast Aug 11, 2021
519d99c
feat: retry failed query jobs in `result()` (#837)
Aug 11, 2021
ad9c802
fix: make unicode characters working well in load_table_from_json (#865)
grimmerk Aug 11, 2021
57d79ce
Merge remote-tracking branch 'upstream/master' into v3-sync
tswast Aug 11, 2021
cf6f0e9
chore: release 2.24.0 (#868)
release-please[bot] Aug 11, 2021
c44d45b
chore(deps): update dependency google-cloud-bigquery to v2.24.0 (#873)
renovate-bot Aug 12, 2021
02bb6fd
Merge remote-tracking branch 'upstream/master' into v3-sync
tswast Aug 12, 2021
a00d724
chore: remove duplicate warning from bad merge
tswast Aug 12, 2021
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/repo-automation-bots/owlbot-python:latest
digest: sha256:aea14a583128771ae8aefa364e1652f3c56070168ef31beb203534222d842b8b
digest: sha256:50e35228649c47b6ca82aa0be3ff9eb2afce51c82b66c4a03fe4afeb5ff6c0fc
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
* @googleapis/api-bigquery @googleapis/yoshi-python

# The python-samples-reviewers team is the default owner for samples changes
/samples/ @googleapis/api-bigquery @googleapis/python-samples-owners
/samples/ @googleapis/api-bigquery @googleapis/python-samples-owners @googleapis/yoshi-python
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
[1]: https://pypi.org/project/google-cloud-bigquery/#history


### [2.23.3](https://www.github.com/googleapis/python-bigquery/compare/v2.23.2...v2.23.3) (2021-08-06)


### Bug Fixes

* increase default retry deadline to 10 minutes ([#859](https://www.github.com/googleapis/python-bigquery/issues/859)) ([30770fd](https://www.github.com/googleapis/python-bigquery/commit/30770fd0575fbd5aaa70c14196a4cc54627aecd2))

### [2.23.2](https://www.github.com/googleapis/python-bigquery/compare/v2.23.1...v2.23.2) (2021-07-29)


Expand Down
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
# directories to ignore when looking for source files.
exclude_patterns = [
"_build",
"**/.nox/**/*",
"samples/AUTHORING_GUIDE.md",
"samples/CONTRIBUTING.md",
"samples/snippets/README.rst",
Expand Down
2 changes: 2 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Job-Related Types
job.SourceFormat
job.WriteDisposition
job.SchemaUpdateOption
job.TransactionInfo


Dataset
Expand Down Expand Up @@ -137,6 +138,7 @@ Query

query.ArrayQueryParameter
query.ScalarQueryParameter
query.ScalarQueryParameterType
query.StructQueryParameter
query.UDFResource

Expand Down
2 changes: 2 additions & 0 deletions google/cloud/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from google.cloud.bigquery.job import ScriptOptions
from google.cloud.bigquery.job import SourceFormat
from google.cloud.bigquery.job import UnknownJob
from google.cloud.bigquery.job import TransactionInfo
from google.cloud.bigquery.job import WriteDisposition
from google.cloud.bigquery.model import Model
from google.cloud.bigquery.model import ModelReference
Expand Down Expand Up @@ -148,6 +149,7 @@
"GoogleSheetsOptions",
"ParquetOptions",
"ScriptOptions",
"TransactionInfo",
"DEFAULT_RETRY",
# Enum Constants
"enums",
Expand Down
24 changes: 12 additions & 12 deletions google/cloud/bigquery/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,23 @@ class SqlTypeNames(str, enum.Enum):
class SqlParameterScalarTypes:
"""Supported scalar SQL query parameter types as type objects."""

STRING = ScalarQueryParameterType("STRING")
BOOL = ScalarQueryParameterType("BOOL")
BOOLEAN = ScalarQueryParameterType("BOOL")
BIGDECIMAL = ScalarQueryParameterType("BIGNUMERIC")
BIGNUMERIC = ScalarQueryParameterType("BIGNUMERIC")
BYTES = ScalarQueryParameterType("BYTES")
INTEGER = ScalarQueryParameterType("INT64")
INT64 = ScalarQueryParameterType("INT64")
DATE = ScalarQueryParameterType("DATE")
DATETIME = ScalarQueryParameterType("DATETIME")
DECIMAL = ScalarQueryParameterType("NUMERIC")
FLOAT = ScalarQueryParameterType("FLOAT64")
FLOAT64 = ScalarQueryParameterType("FLOAT64")
NUMERIC = ScalarQueryParameterType("NUMERIC")
BIGNUMERIC = ScalarQueryParameterType("BIGNUMERIC")
DECIMAL = ScalarQueryParameterType("NUMERIC")
BIGDECIMAL = ScalarQueryParameterType("BIGNUMERIC")
BOOLEAN = ScalarQueryParameterType("BOOL")
BOOL = ScalarQueryParameterType("BOOL")
GEOGRAPHY = ScalarQueryParameterType("GEOGRAPHY")
TIMESTAMP = ScalarQueryParameterType("TIMESTAMP")
DATE = ScalarQueryParameterType("DATE")
INT64 = ScalarQueryParameterType("INT64")
INTEGER = ScalarQueryParameterType("INT64")
NUMERIC = ScalarQueryParameterType("NUMERIC")
STRING = ScalarQueryParameterType("STRING")
TIME = ScalarQueryParameterType("TIME")
DATETIME = ScalarQueryParameterType("DATETIME")
TIMESTAMP = ScalarQueryParameterType("TIMESTAMP")


class WriteDisposition(object):
Expand Down
2 changes: 2 additions & 0 deletions google/cloud/bigquery/job/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from google.cloud.bigquery.job.base import ReservationUsage
from google.cloud.bigquery.job.base import ScriptStatistics
from google.cloud.bigquery.job.base import ScriptStackFrame
from google.cloud.bigquery.job.base import TransactionInfo
from google.cloud.bigquery.job.base import UnknownJob
from google.cloud.bigquery.job.copy_ import CopyJob
from google.cloud.bigquery.job.copy_ import CopyJobConfig
Expand Down Expand Up @@ -81,5 +82,6 @@
"QueryPriority",
"SchemaUpdateOption",
"SourceFormat",
"TransactionInfo",
"WriteDisposition",
]
29 changes: 29 additions & 0 deletions google/cloud/bigquery/job/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import http
import threading
import typing
from typing import Dict, Optional

from google.api_core import exceptions
import google.api_core.future.polling
Expand Down Expand Up @@ -88,6 +89,22 @@ def _error_result_to_exception(error_result):
)


class TransactionInfo(typing.NamedTuple):
"""[Alpha] Information of a multi-statement transaction.

https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#TransactionInfo

.. versionadded:: 2.24.0
"""

transaction_id: str
"""Output only. ID of the transaction."""

@classmethod
def from_api_repr(cls, transaction_info: Dict[str, str]) -> "TransactionInfo":
return cls(transaction_info["transactionId"])


class _JobReference(object):
"""A reference to a job.

Expand Down Expand Up @@ -336,6 +353,18 @@ def reservation_usage(self):
for usage in usage_stats_raw
]

@property
def transaction_info(self) -> Optional[TransactionInfo]:
"""Information of the multi-statement transaction if this job is part of one.

.. versionadded:: 2.24.0
"""
info = self._properties.get("statistics", {}).get("transactionInfo")
if info is None:
return None
else:
return TransactionInfo.from_api_repr(info)

@property
def error_result(self):
"""Error information about the job as a whole.
Expand Down
42 changes: 30 additions & 12 deletions google/cloud/bigquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@

from collections import OrderedDict
import copy
from typing import Union
import datetime
import decimal
from typing import Optional, Union

from google.cloud.bigquery.table import _parse_schema_resource
from google.cloud.bigquery._helpers import _rows_from_json
from google.cloud.bigquery._helpers import _QUERY_PARAMS_FROM_JSON
from google.cloud.bigquery._helpers import _SCALAR_VALUE_TO_JSON_PARAM


_SCALAR_VALUE_TYPE = Optional[
Union[str, int, float, decimal.Decimal, bool, datetime.datetime, datetime.date]
]


class UDFResource(object):
"""Describe a single user-defined function (UDF) resource.

Expand Down Expand Up @@ -325,35 +332,46 @@ class ScalarQueryParameter(_AbstractQueryParameter):
"""Named / positional query parameters for scalar values.

Args:
name (Optional[str]):
name:
Parameter name, used via ``@foo`` syntax. If None, the
parameter can only be addressed via position (``?``).

type_ (str):
Name of parameter type. One of 'STRING', 'INT64',
'FLOAT64', 'NUMERIC', 'BIGNUMERIC', 'BOOL', 'TIMESTAMP', 'DATETIME', or
'DATE'.
type_:
Name of parameter type. See
:class:`google.cloud.bigquery.enums.SqlTypeNames` and
:class:`google.cloud.bigquery.enums.SqlParameterScalarTypes` for
supported types.

value (Union[str, int, float, decimal.Decimal, bool, datetime.datetime, datetime.date]):
value:
The scalar parameter value.
"""

def __init__(self, name, type_, value):
def __init__(
self,
name: Optional[str],
type_: Optional[Union[str, ScalarQueryParameterType]],
value: _SCALAR_VALUE_TYPE,
):
self.name = name
self.type_ = type_
if isinstance(type_, ScalarQueryParameterType):
self.type_ = type_._type
else:
self.type_ = type_
self.value = value

@classmethod
def positional(cls, type_: str, value) -> "ScalarQueryParameter":
def positional(
cls, type_: Union[str, ScalarQueryParameterType], value: _SCALAR_VALUE_TYPE
) -> "ScalarQueryParameter":
"""Factory for positional paramater.

Args:
type_ (str):
type_:
Name of parameter type. One of 'STRING', 'INT64',
'FLOAT64', 'NUMERIC', 'BIGNUMERIC', 'BOOL', 'TIMESTAMP', 'DATETIME', or
'DATE'.

value (Union[str, int, float, decimal.Decimal, bool, datetime.datetime, datetime.date]):
value:
The scalar parameter value.

Returns:
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _should_retry(exc):
return reason in _RETRYABLE_REASONS


DEFAULT_RETRY = retry.Retry(predicate=_should_retry)
DEFAULT_RETRY = retry.Retry(predicate=_should_retry, deadline=600.0)
"""The default retry object.

Any method with a ``retry`` parameter will be retried automatically,
Expand Down
44 changes: 42 additions & 2 deletions google/cloud/bigquery/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,16 @@ def _key(self):
return (self._project, self._dataset_id, self._table_id)

def __eq__(self, other):
if not isinstance(other, TableReference):
if isinstance(other, (Table, TableListItem)):
return (
self.project == other.project
and self.dataset_id == other.dataset_id
and self.table_id == other.table_id
)
elif isinstance(other, TableReference):
return self._key() == other._key()
else:
return NotImplemented
return self._key() == other._key()

def __ne__(self, other):
return not self == other
Expand Down Expand Up @@ -1003,6 +1010,24 @@ def _build_resource(self, filter_fields):
"""Generate a resource for ``update``."""
return _helpers._build_resource_from_properties(self, filter_fields)

def __eq__(self, other):
if isinstance(other, Table):
return (
self._properties["tableReference"]
== other._properties["tableReference"]
)
elif isinstance(other, (TableReference, TableListItem)):
return (
self.project == other.project
and self.dataset_id == other.dataset_id
and self.table_id == other.table_id
)
else:
return NotImplemented

def __hash__(self):
return hash((self.project, self.dataset_id, self.table_id))

def __repr__(self):
return "Table({})".format(repr(self.reference))

Expand Down Expand Up @@ -1221,6 +1246,19 @@ def to_api_repr(self) -> dict:
"""
return copy.deepcopy(self._properties)

def __eq__(self, other):
if isinstance(other, (Table, TableReference, TableListItem)):
return (
self.project == other.project
and self.dataset_id == other.dataset_id
and self.table_id == other.table_id
)
else:
return NotImplemented

def __hash__(self):
return hash((self.project, self.dataset_id, self.table_id))


def _row_from_mapping(mapping, schema):
"""Convert a mapping to a row tuple using the schema.
Expand Down Expand Up @@ -1690,6 +1728,8 @@ def to_arrow(
"""
self._maybe_warn_max_results(bqstorage_client)

self._maybe_warn_max_results(bqstorage_client)

if not self._validate_bqstorage(bqstorage_client, create_bqstorage_client):
create_bqstorage_client = False
bqstorage_client = None
Expand Down
2 changes: 1 addition & 1 deletion google/cloud/bigquery/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "2.23.2"
__version__ = "2.23.3"
5 changes: 4 additions & 1 deletion samples/geography/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ def get_pytest_env_vars() -> Dict[str, str]:

TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])

INSTALL_LIBRARY_FROM_SOURCE = bool(os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False))
INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in (
"True",
"true",
)
#
# Style Checks
#
Expand Down
4 changes: 2 additions & 2 deletions samples/geography/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
geojson==2.5.0
google-cloud-bigquery==2.23.2
google-cloud-bigquery-storage==2.6.2
google-cloud-bigquery==2.23.3
google-cloud-bigquery-storage==2.6.3
Shapely==1.7.1
5 changes: 4 additions & 1 deletion samples/snippets/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,10 @@ def get_pytest_env_vars() -> Dict[str, str]:

TESTED_VERSIONS = sorted([v for v in ALL_VERSIONS if v not in IGNORED_VERSIONS])

INSTALL_LIBRARY_FROM_SOURCE = bool(os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False))
INSTALL_LIBRARY_FROM_SOURCE = os.environ.get("INSTALL_LIBRARY_FROM_SOURCE", False) in (
"True",
"true",
)
#
# Style Checks
#
Expand Down
4 changes: 2 additions & 2 deletions samples/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
google-cloud-bigquery==2.23.2
google-cloud-bigquery-storage==2.6.2
google-cloud-bigquery==2.23.3
google-cloud-bigquery-storage==2.6.3
google-auth-oauthlib==0.4.5
grpcio==1.39.0
ipython==7.16.1; python_version < '3.7'
Expand Down
Loading