Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 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
dbb2a28
chore: sync new changes from master
plamut Aug 5, 2021
cf0b0d8
chore: add api-bigquery as a samples owner (#852)
busunkim96 Aug 5, 2021
4cd6d49
Merge remote-tracking branch 'upstream/master' into sync-master
tswast Aug 5, 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/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/python-samples-owners
/samples/ @googleapis/api-bigquery @googleapis/python-samples-owners
15 changes: 14 additions & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,20 @@
branchProtectionRules:
# Identifies the protection rule pattern. Name of the branch to be protected.
# Defaults to `master`
- pattern: '{master,v3}'
- pattern: master
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
requiredStatusCheckContexts:
- 'Kokoro'
- 'Kokoro snippets-3.8'
- 'cla/google'
- 'Samples - Lint'
- 'Samples - Python 3.6'
- 'Samples - Python 3.7'
- 'Samples - Python 3.8'
- pattern: v3
requiresCodeOwnerReviews: true
requiresStrictStatusChecks: true
requiredStatusCheckContexts:
- 'Kokoro'
- 'Kokoro snippets-3.8'
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
[1]: https://pypi.org/project/google-cloud-bigquery/#history


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


### Dependencies

* expand pyarrow pins to support 5.x releases ([#833](https://www.github.com/googleapis/python-bigquery/issues/833)) ([80e3a61](https://www.github.com/googleapis/python-bigquery/commit/80e3a61c60419fb19b70b664c6415cd01ba82f5b))

### [2.23.1](https://www.github.com/googleapis/python-bigquery/compare/v2.23.0...v2.23.1) (2021-07-28)


### Bug Fixes

* `insert_rows()` accepts float column values as strings again ([#824](https://www.github.com/googleapis/python-bigquery/issues/824)) ([d9378af](https://www.github.com/googleapis/python-bigquery/commit/d9378af13add879118a1d004529b811f72c325d6))

## [2.23.0](https://www.github.com/googleapis/python-bigquery/compare/v2.22.1...v2.23.0) (2021-07-27)


Expand Down
12 changes: 7 additions & 5 deletions google/cloud/bigquery/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import decimal
import math
import re
from typing import Union

from google.cloud._helpers import UTC
from google.cloud._helpers import _date_from_iso8601_date
Expand Down Expand Up @@ -312,14 +313,15 @@ def _int_to_json(value):
return value


def _float_to_json(value):
def _float_to_json(value) -> Union[None, str, float]:
"""Coerce 'value' to an JSON-compatible representation."""
if value is None:
return None
elif math.isnan(value) or math.isinf(value):
return str(value)
else:
return float(value)

if isinstance(value, str):
value = float(value)

return str(value) if (math.isnan(value) or math.isinf(value)) else float(value)


def _decimal_to_json(value):
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.0"
__version__ = "2.23.2"
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.22.1
google-cloud-bigquery-storage==2.6.0
google-cloud-bigquery==2.23.2
google-cloud-bigquery-storage==2.6.2
Shapely==1.7.1
2 changes: 1 addition & 1 deletion samples/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
google-cloud-testutils==0.3.0
google-cloud-testutils==1.0.0
pytest==6.2.4
mock==4.0.3
8 changes: 4 additions & 4 deletions samples/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
google-cloud-bigquery==2.22.1
google-cloud-bigquery-storage==2.6.0
google-auth-oauthlib==0.4.4
google-cloud-bigquery==2.23.2
google-cloud-bigquery-storage==2.6.2
google-auth-oauthlib==0.4.5
grpcio==1.39.0
ipython==7.16.1; python_version < '3.7'
ipython==7.17.0; python_version >= '3.7'
matplotlib==3.3.4; python_version < '3.7'
matplotlib==3.4.1; python_version >= '3.7'
pandas==1.1.5; python_version < '3.7'
pandas==1.2.0; python_version >= '3.7'
pyarrow==4.0.1
pyarrow==5.0.0
pytz==2021.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"google-resumable-media >= 0.6.0, < 3.0dev",
"packaging >= 14.3",
"protobuf >= 3.12.0",
"pyarrow >= 3.0.0, < 5.0dev",
"pyarrow >= 3.0.0, < 6.0dev",
"requests >= 2.18.0, < 3.0.0dev",
]
extras = {
Expand Down
40 changes: 26 additions & 14 deletions tests/system/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io
import operator

import google.api_core.retry
import pkg_resources
import pytest
import pytz
Expand All @@ -37,6 +38,10 @@
PANDAS_INT64_VERSION = pkg_resources.parse_version("1.0.0")


class MissingDataError(Exception):
pass


def test_load_table_from_dataframe_w_automatic_schema(bigquery_client, dataset_id):
"""Test that a DataFrame with dtypes that map well to BigQuery types
can be uploaded without specifying a schema.
Expand Down Expand Up @@ -657,27 +662,34 @@ def test_insert_rows_from_dataframe(bigquery_client, dataset_id):
)
for errors in chunk_errors:
assert not errors

# Use query to fetch rows instead of listing directly from the table so
# that we get values from the streaming buffer.
rows = list(
bigquery_client.query(
"SELECT * FROM `{}.{}.{}`".format(
table.project, table.dataset_id, table.table_id
)
)
)

sorted_rows = sorted(rows, key=operator.attrgetter("int_col"))
row_tuples = [r.values() for r in sorted_rows]
expected = [
# Pandas often represents NULL values as NaN. Convert to None for
# easier comparison.
tuple(None if col != col else col for col in data_row)
for data_row in dataframe.itertuples(index=False)
]

assert len(row_tuples) == len(expected)
# Use query to fetch rows instead of listing directly from the table so
# that we get values from the streaming buffer "within a few seconds".
# https://cloud.google.com/bigquery/streaming-data-into-bigquery#dataavailability
@google.api_core.retry.Retry(
predicate=google.api_core.retry.if_exception_type(MissingDataError)
)
def get_rows():
rows = list(
bigquery_client.query(
"SELECT * FROM `{}.{}.{}`".format(
table.project, table.dataset_id, table.table_id
)
)
)
if len(rows) != len(expected):
raise MissingDataError()
return rows

rows = get_rows()
sorted_rows = sorted(rows, key=operator.attrgetter("int_col"))
row_tuples = [r.values() for r in sorted_rows]

for row, expected_row in zip(row_tuples, expected):
assert (
Expand Down
24 changes: 24 additions & 0 deletions tests/unit/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,21 +653,45 @@ def _call_fut(self, value):
def test_w_none(self):
self.assertEqual(self._call_fut(None), None)

def test_w_non_numeric(self):
with self.assertRaises(TypeError):
self._call_fut(object())

def test_w_integer(self):
result = self._call_fut(123)
self.assertIsInstance(result, float)
self.assertEqual(result, 123.0)

def test_w_float(self):
self.assertEqual(self._call_fut(1.23), 1.23)

def test_w_float_as_string(self):
self.assertEqual(self._call_fut("1.23"), 1.23)

def test_w_nan(self):
result = self._call_fut(float("nan"))
self.assertEqual(result.lower(), "nan")

def test_w_nan_as_string(self):
result = self._call_fut("NaN")
self.assertEqual(result.lower(), "nan")

def test_w_infinity(self):
result = self._call_fut(float("inf"))
self.assertEqual(result.lower(), "inf")

def test_w_infinity_as_string(self):
result = self._call_fut("inf")
self.assertEqual(result.lower(), "inf")

def test_w_negative_infinity(self):
result = self._call_fut(float("-inf"))
self.assertEqual(result.lower(), "-inf")

def test_w_negative_infinity_as_string(self):
result = self._call_fut("-inf")
self.assertEqual(result.lower(), "-inf")


class Test_decimal_to_json(unittest.TestCase):
def _call_fut(self, value):
Expand Down