Skip to content

Commit

Permalink
fix: error using empty array of structs parameter (#474)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* 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 <[email protected]>
  • Loading branch information
plamut and tswast authored Feb 24, 2021
1 parent cc3394f commit c1d15f4
Show file tree
Hide file tree
Showing 5 changed files with 711 additions and 15 deletions.
6 changes: 6 additions & 0 deletions google/cloud/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -93,6 +96,9 @@
"ArrayQueryParameter",
"ScalarQueryParameter",
"StructQueryParameter",
"ArrayQueryParameterType",
"ScalarQueryParameterType",
"StructQueryParameterType",
# Datasets
"Dataset",
"DatasetReference",
Expand Down
21 changes: 21 additions & 0 deletions google/cloud/bigquery/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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.
Expand Down
Loading

0 comments on commit c1d15f4

Please sign in to comment.