Skip to content
Permalink
Browse files
fix: error using empty array of structs parameter (#474)
* fix: error using empty array of structs parameter

* Add QueryParameterType classes

* Use query parameter types with ArrayQueryParameter

* Adjust system test to changed ArrayQueryParameter

* Clarify a comment about an assertion

Co-authored-by: Tim Swast <swast@google.com>

* Clarify when name/descr. is omitted from API repr

* Rename subtypes to fields

* Add fields property to StructQueryParameterType

* Add a check for empty struct fields

* Define scalar SQL parameter types as type objects

Co-authored-by: Tim Swast <swast@google.com>
  • Loading branch information
plamut and tswast committed Feb 24, 2021
1 parent cc3394f commit c1d15f4e5da4b7e10c00afffd59a5c7f3ded027a
Showing with 711 additions and 15 deletions.
  1. +6 −0 google/cloud/bigquery/__init__.py
  2. +21 −0 google/cloud/bigquery/enums.py
  3. +287 −14 google/cloud/bigquery/query.py
  4. +15 −0 tests/system/test_client.py
  5. +382 −1 tests/unit/test_query.py
@@ -66,8 +66,11 @@
from google.cloud.bigquery.model import Model
from google.cloud.bigquery.model import ModelReference
from google.cloud.bigquery.query import ArrayQueryParameter
from google.cloud.bigquery.query import ArrayQueryParameterType
from google.cloud.bigquery.query import ScalarQueryParameter
from google.cloud.bigquery.query import ScalarQueryParameterType
from google.cloud.bigquery.query import StructQueryParameter
from google.cloud.bigquery.query import StructQueryParameterType
from google.cloud.bigquery.query import UDFResource
from google.cloud.bigquery.retry import DEFAULT_RETRY
from google.cloud.bigquery.routine import DeterminismLevel
@@ -93,6 +96,9 @@
"ArrayQueryParameter",
"ScalarQueryParameter",
"StructQueryParameter",
"ArrayQueryParameterType",
"ScalarQueryParameterType",
"StructQueryParameterType",
# Datasets
"Dataset",
"DatasetReference",
@@ -18,6 +18,7 @@
import itertools

from google.cloud.bigquery_v2 import types as gapic_types
from google.cloud.bigquery.query import ScalarQueryParameterType


class Compression(object):
@@ -215,6 +216,26 @@ class SqlTypeNames(str, enum.Enum):
DATETIME = "DATETIME"


class SqlParameterScalarTypes:
"""Supported scalar SQL query parameter types as type objects."""

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


class WriteDisposition(object):
"""Specifies the action that occurs if destination table already exists.
Loading

0 comments on commit c1d15f4

Please sign in to comment.