Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit a7842b6

Browse files
authored
chore!: remove google.cloud.bigquery_v2 code (#855)
Closes #814. The first preview. Still need to address Model types, disable code generation, BigQuery ML classes... **PR checklist:** - [x] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [x] Ensure the tests and linter pass - [x] Code coverage does not decrease (if any source code was changed) - [x] Appropriate docs were updated (if necessary)
1 parent 2cb1c21 commit a7842b6

39 files changed

+1327
-2628
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Types for Google Cloud Bigquery v2 API
22
======================================
33

4-
.. automodule:: google.cloud.bigquery_v2.types
4+
.. automodule:: google.cloud.bigquery.standard_sql
55
:members:
66
:undoc-members:
77
:show-inheritance:

docs/conf.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@
114114
"samples/AUTHORING_GUIDE.md",
115115
"samples/CONTRIBUTING.md",
116116
"samples/snippets/README.rst",
117-
"bigquery_v2/services.rst", # generated by the code generator
118117
]
119118

120119
# The reST default role (used for this markup: `text`) to use for all
@@ -364,8 +363,6 @@
364363
"google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
365364
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
366365
"grpc": ("https://grpc.github.io/grpc/python/", None),
367-
"proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
368-
"protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
369366
"pandas": ("http://pandas.pydata.org/pandas-docs/dev", None),
370367
"geopandas": ("https://geopandas.org/", None),
371368
}

docs/reference.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ Encryption Configuration
197197
Additional Types
198198
================
199199

200-
Protocol buffer classes for working with the Models API.
200+
Helper SQL type classes.
201201

202202
.. toctree::
203203
:maxdepth: 2
204204

205-
bigquery_v2/types
205+
bigquery/standard_sql

google/cloud/bigquery/__init__.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from google.cloud.bigquery.enums import DecimalTargetType
4242
from google.cloud.bigquery.enums import KeyResultStatementKind
4343
from google.cloud.bigquery.enums import SqlTypeNames
44-
from google.cloud.bigquery.enums import StandardSqlDataTypes
44+
from google.cloud.bigquery.enums import StandardSqlTypeNames
4545
from google.cloud.bigquery.external_config import ExternalConfig
4646
from google.cloud.bigquery.external_config import BigtableOptions
4747
from google.cloud.bigquery.external_config import BigtableColumnFamily
@@ -77,6 +77,7 @@
7777
from google.cloud.bigquery.query import ArrayQueryParameterType
7878
from google.cloud.bigquery.query import ScalarQueryParameter
7979
from google.cloud.bigquery.query import ScalarQueryParameterType
80+
from google.cloud.bigquery.query import SqlParameterScalarTypes
8081
from google.cloud.bigquery.query import StructQueryParameter
8182
from google.cloud.bigquery.query import StructQueryParameterType
8283
from google.cloud.bigquery.query import UDFResource
@@ -87,6 +88,10 @@
8788
from google.cloud.bigquery.routine import RoutineReference
8889
from google.cloud.bigquery.routine import RoutineType
8990
from google.cloud.bigquery.schema import SchemaField
91+
from google.cloud.bigquery.standard_sql import StandardSqlDataType
92+
from google.cloud.bigquery.standard_sql import StandardSqlField
93+
from google.cloud.bigquery.standard_sql import StandardSqlStructType
94+
from google.cloud.bigquery.standard_sql import StandardSqlTableType
9095
from google.cloud.bigquery.table import PartitionRange
9196
from google.cloud.bigquery.table import RangePartitioning
9297
from google.cloud.bigquery.table import Row
@@ -108,6 +113,7 @@
108113
"StructQueryParameter",
109114
"ArrayQueryParameterType",
110115
"ScalarQueryParameterType",
116+
"SqlParameterScalarTypes",
111117
"StructQueryParameterType",
112118
# Datasets
113119
"Dataset",
@@ -151,6 +157,11 @@
151157
"ScriptOptions",
152158
"TransactionInfo",
153159
"DEFAULT_RETRY",
160+
# Standard SQL types
161+
"StandardSqlDataType",
162+
"StandardSqlField",
163+
"StandardSqlStructType",
164+
"StandardSqlTableType",
154165
# Enum Constants
155166
"enums",
156167
"AutoRowIDs",
@@ -168,7 +179,7 @@
168179
"SchemaUpdateOption",
169180
"SourceFormat",
170181
"SqlTypeNames",
171-
"StandardSqlDataTypes",
182+
"StandardSqlTypeNames",
172183
"WriteDisposition",
173184
# EncryptionConfiguration
174185
"EncryptionConfiguration",

google/cloud/bigquery/dbapi/_helpers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import typing
2323

2424
from google.cloud import bigquery
25-
from google.cloud.bigquery import table, enums, query
25+
from google.cloud.bigquery import table, query
2626
from google.cloud.bigquery.dbapi import exceptions
2727

2828

@@ -48,7 +48,7 @@ def _parameter_type(name, value, query_parameter_type=None, value_doc=""):
4848
query_parameter_type = type_parameters_re.sub("", query_parameter_type)
4949
try:
5050
parameter_type = getattr(
51-
enums.SqlParameterScalarTypes, query_parameter_type.upper()
51+
query.SqlParameterScalarTypes, query_parameter_type.upper()
5252
)._type
5353
except AttributeError:
5454
raise exceptions.ProgrammingError(
@@ -185,7 +185,7 @@ def _parse_type(
185185
# Strip type parameters
186186
type_ = type_parameters_re.sub("", type_).strip()
187187
try:
188-
type_ = getattr(enums.SqlParameterScalarTypes, type_.upper())
188+
type_ = getattr(query.SqlParameterScalarTypes, type_.upper())
189189
except AttributeError:
190190
raise exceptions.ProgrammingError(
191191
f"The given parameter type, {type_},"

google/cloud/bigquery/enums.py

Lines changed: 21 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import re
16-
1715
import enum
18-
import itertools
19-
20-
from google.cloud.bigquery_v2 import types as gapic_types
21-
from google.cloud.bigquery.query import ScalarQueryParameterType
2216

2317

2418
class AutoRowIDs(enum.Enum):
@@ -180,56 +174,27 @@ class KeyResultStatementKind:
180174
FIRST_SELECT = "FIRST_SELECT"
181175

182176

183-
_SQL_SCALAR_TYPES = frozenset(
184-
(
185-
"INT64",
186-
"BOOL",
187-
"FLOAT64",
188-
"STRING",
189-
"BYTES",
190-
"TIMESTAMP",
191-
"DATE",
192-
"TIME",
193-
"DATETIME",
194-
"INTERVAL",
195-
"GEOGRAPHY",
196-
"NUMERIC",
197-
"BIGNUMERIC",
198-
"JSON",
199-
)
200-
)
201-
202-
_SQL_NONSCALAR_TYPES = frozenset(("TYPE_KIND_UNSPECIFIED", "ARRAY", "STRUCT"))
203-
204-
205-
def _make_sql_scalars_enum():
206-
"""Create an enum based on a gapic enum containing only SQL scalar types."""
207-
208-
new_enum = enum.Enum(
209-
"StandardSqlDataTypes",
210-
(
211-
(member.name, member.value)
212-
for member in gapic_types.StandardSqlDataType.TypeKind
213-
if member.name in _SQL_SCALAR_TYPES
214-
),
215-
)
216-
217-
# make sure the docstring for the new enum is also correct
218-
orig_doc = gapic_types.StandardSqlDataType.TypeKind.__doc__
219-
skip_pattern = re.compile(
220-
"|".join(_SQL_NONSCALAR_TYPES)
221-
+ "|because a JSON object" # the second description line of STRUCT member
222-
)
223-
224-
new_doc = "\n".join(
225-
itertools.filterfalse(skip_pattern.search, orig_doc.splitlines())
226-
)
227-
new_enum.__doc__ = "An Enum of scalar SQL types.\n" + new_doc
228-
229-
return new_enum
230-
231-
232-
StandardSqlDataTypes = _make_sql_scalars_enum()
177+
class StandardSqlTypeNames(str, enum.Enum):
178+
def _generate_next_value_(name, start, count, last_values):
179+
return name
180+
181+
TYPE_KIND_UNSPECIFIED = enum.auto()
182+
INT64 = enum.auto()
183+
BOOL = enum.auto()
184+
FLOAT64 = enum.auto()
185+
STRING = enum.auto()
186+
BYTES = enum.auto()
187+
TIMESTAMP = enum.auto()
188+
DATE = enum.auto()
189+
TIME = enum.auto()
190+
DATETIME = enum.auto()
191+
INTERVAL = enum.auto()
192+
GEOGRAPHY = enum.auto()
193+
NUMERIC = enum.auto()
194+
BIGNUMERIC = enum.auto()
195+
JSON = enum.auto()
196+
ARRAY = enum.auto()
197+
STRUCT = enum.auto()
233198

234199

235200
# See also: https://cloud.google.com/bigquery/data-types#legacy_sql_data_types
@@ -256,28 +221,6 @@ class SqlTypeNames(str, enum.Enum):
256221
DATETIME = "DATETIME"
257222

258223

259-
class SqlParameterScalarTypes:
260-
"""Supported scalar SQL query parameter types as type objects."""
261-
262-
BOOL = ScalarQueryParameterType("BOOL")
263-
BOOLEAN = ScalarQueryParameterType("BOOL")
264-
BIGDECIMAL = ScalarQueryParameterType("BIGNUMERIC")
265-
BIGNUMERIC = ScalarQueryParameterType("BIGNUMERIC")
266-
BYTES = ScalarQueryParameterType("BYTES")
267-
DATE = ScalarQueryParameterType("DATE")
268-
DATETIME = ScalarQueryParameterType("DATETIME")
269-
DECIMAL = ScalarQueryParameterType("NUMERIC")
270-
FLOAT = ScalarQueryParameterType("FLOAT64")
271-
FLOAT64 = ScalarQueryParameterType("FLOAT64")
272-
GEOGRAPHY = ScalarQueryParameterType("GEOGRAPHY")
273-
INT64 = ScalarQueryParameterType("INT64")
274-
INTEGER = ScalarQueryParameterType("INT64")
275-
NUMERIC = ScalarQueryParameterType("NUMERIC")
276-
STRING = ScalarQueryParameterType("STRING")
277-
TIME = ScalarQueryParameterType("TIME")
278-
TIMESTAMP = ScalarQueryParameterType("TIMESTAMP")
279-
280-
281224
class WriteDisposition(object):
282225
"""Specifies the action that occurs if destination table already exists.
283226

0 commit comments

Comments
 (0)