diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 0e71e2aca..cb81a05f8 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -15,7 +15,11 @@ set -eo pipefail -cd github/python-bigquery +if [[ -z "${PROJECT_ROOT:-}" ]]; then + PROJECT_ROOT="github/python-bigquery" +fi + +cd "${PROJECT_ROOT}" # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 diff --git a/.kokoro/docs/docs-presubmit.cfg b/.kokoro/docs/docs-presubmit.cfg index 111810782..5c216b4bc 100644 --- a/.kokoro/docs/docs-presubmit.cfg +++ b/.kokoro/docs/docs-presubmit.cfg @@ -15,3 +15,14 @@ env_vars: { key: "TRAMPOLINE_IMAGE_UPLOAD" value: "false" } + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-bigquery/.kokoro/build.sh" +} + +# Only run this nox session. +env_vars: { + key: "NOX_SESSION" + value: "docs docfx" +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c0233bbd4..d01f62ff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://pypi.org/project/google-cloud-bigquery/#history +### [2.6.1](https://www.github.com/googleapis/python-bigquery/compare/v2.6.0...v2.6.1) (2020-12-09) + + +### Bug Fixes + +* handle null values in array query parameters ([#426](https://www.github.com/googleapis/python-bigquery/issues/426)) ([78fde4a](https://www.github.com/googleapis/python-bigquery/commit/78fde4a92e61a89d0b490b93acc90fff9635d1bf)) + + +### Documentation + +* add examples of `fields` argument to update methods ([#418](https://www.github.com/googleapis/python-bigquery/issues/418)) ([8c7e02b](https://www.github.com/googleapis/python-bigquery/commit/8c7e02b0de2c92ee965414e7c430eb57d1877326)) + ## [2.6.0](https://www.github.com/googleapis/python-bigquery/compare/v2.5.0...v2.6.0) (2020-12-07) diff --git a/google/cloud/bigquery/_helpers.py b/google/cloud/bigquery/_helpers.py index 716c8a394..100136108 100644 --- a/google/cloud/bigquery/_helpers.py +++ b/google/cloud/bigquery/_helpers.py @@ -40,7 +40,7 @@ def _not_null(value, field): """Check whether 'value' should be coerced to 'field' type.""" - return value is not None or field.mode != "NULLABLE" + return value is not None or (field is not None and field.mode != "NULLABLE") def _int_from_json(value, field): diff --git a/google/cloud/bigquery/client.py b/google/cloud/bigquery/client.py index c7cd694c6..28cac64ad 100644 --- a/google/cloud/bigquery/client.py +++ b/google/cloud/bigquery/client.py @@ -881,7 +881,22 @@ def update_dataset(self, dataset, fields, retry=DEFAULT_RETRY, timeout=None): dataset (google.cloud.bigquery.dataset.Dataset): The dataset to update. fields (Sequence[str]): - The properties of ``dataset`` to change (e.g. "friendly_name"). + The properties of ``dataset`` to change. These are strings + corresponding to the properties of + :class:`~google.cloud.bigquery.dataset.Dataset`. + + For example, to update the default expiration times, specify + both properties in the ``fields`` argument: + + .. code-block:: python + + bigquery_client.update_dataset( + dataset, + [ + "default_partition_expiration_ms", + "default_table_expiration_ms", + ] + ) retry (Optional[google.api_core.retry.Retry]): How to retry the RPC. timeout (Optional[float]): @@ -928,8 +943,18 @@ def update_model(self, model, fields, retry=DEFAULT_RETRY, timeout=None): Args: model (google.cloud.bigquery.model.Model): The model to update. fields (Sequence[str]): - The fields of ``model`` to change, spelled as the Model - properties (e.g. "friendly_name"). + The properties of ``model`` to change. These are strings + corresponding to the properties of + :class:`~google.cloud.bigquery.model.Model`. + + For example, to update the descriptive properties of the model, + specify them in the ``fields`` argument: + + .. code-block:: python + + bigquery_client.update_model( + model, ["description", "friendly_name"] + ) retry (Optional[google.api_core.retry.Retry]): A description of how to retry the API call. timeout (Optional[float]): @@ -980,11 +1005,20 @@ def update_routine(self, routine, fields, retry=DEFAULT_RETRY, timeout=None): occurred since the read. Args: - routine (google.cloud.bigquery.routine.Routine): The routine to update. + routine (google.cloud.bigquery.routine.Routine): + The routine to update. fields (Sequence[str]): The fields of ``routine`` to change, spelled as the - :class:`~google.cloud.bigquery.routine.Routine` properties - (e.g. ``type_``). + :class:`~google.cloud.bigquery.routine.Routine` properties. + + For example, to update the description property of the routine, + specify it in the ``fields`` argument: + + .. code-block:: python + + bigquery_client.update_routine( + routine, ["description"] + ) retry (Optional[google.api_core.retry.Retry]): A description of how to retry the API call. timeout (Optional[float]): @@ -1035,8 +1069,18 @@ def update_table(self, table, fields, retry=DEFAULT_RETRY, timeout=None): Args: table (google.cloud.bigquery.table.Table): The table to update. fields (Sequence[str]): - The fields of ``table`` to change, spelled as the Table - properties (e.g. "friendly_name"). + The fields of ``table`` to change, spelled as the + :class:`~google.cloud.bigquery.table.Table` properties. + + For example, to update the descriptive properties of the table, + specify them in the ``fields`` argument: + + .. code-block:: python + + bigquery_client.update_table( + table, + ["description", "friendly_name"] + ) retry (Optional[google.api_core.retry.Retry]): A description of how to retry the API call. timeout (Optional[float]): diff --git a/google/cloud/bigquery/version.py b/google/cloud/bigquery/version.py index ae34a9fbe..410cd066e 100644 --- a/google/cloud/bigquery/version.py +++ b/google/cloud/bigquery/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "2.6.0" +__version__ = "2.6.1" diff --git a/noxfile.py b/noxfile.py index 441782583..95818d3c8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -25,6 +25,18 @@ BLACK_PATHS = ("docs", "google", "samples", "tests", "noxfile.py", "setup.py") CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() +# 'docfx' is excluded since it only needs to run in 'docs-presubmit' +nox.options.sessions = [ + "unit", + "system", + "snippets", + "cover", + "lint", + "lint_setup_py", + "blacken", + "docs", +] + def default(session): """Default unit test session. diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 3eecbf546..1d3cace2b 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,10 +1,10 @@ -google-cloud-bigquery==2.5.0 -google-cloud-bigquery-storage==2.0.1 +google-cloud-bigquery==2.6.0 +google-cloud-bigquery-storage==2.1.0 google-auth-oauthlib==0.4.2 grpcio==1.34.0 ipython==7.16.1; python_version < '3.7' ipython==7.17.0; python_version >= '3.7' matplotlib==3.3.3 -pandas==1.1.4 +pandas==1.1.5 pyarrow==2.0.0 pytz==2020.4 diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index a7c639ed1..cf268daf1 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -383,6 +383,16 @@ def test_from_api_repr_wo_values(self): self.assertEqual(param.array_type, "INT64") self.assertEqual(param.values, []) + def test_from_api_repr_w_none_values(self): + RESOURCE = { + "parameterType": {"type": "ARRAY", "arrayType": {"type": "INT64"}}, + "parameterValue": {"arrayValues": [{"value": "1"}, {"value": None}]}, + } + klass = self._get_target_class() + param = klass.from_api_repr(RESOURCE) + self.assertEqual(param.array_type, "INT64") + self.assertEqual(param.values, [1, None]) + def test_from_api_repr_w_struct_type(self): from google.cloud.bigquery.query import StructQueryParameter