sqlalchemy-bigquery 1.10.0__tar.gz → 1.11.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/AUTHORS +1 -0
- {sqlalchemy-bigquery-1.10.0/sqlalchemy_bigquery.egg-info → sqlalchemy-bigquery-1.11.0}/PKG-INFO +13 -14
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/README.rst +3 -4
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/setup.py +2 -2
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/_struct.py +12 -32
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/base.py +56 -31
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/requirements.py +5 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/version.py +1 -1
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0/sqlalchemy_bigquery.egg-info}/PKG-INFO +13 -14
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/requires.txt +8 -8
- sqlalchemy-bigquery-1.11.0/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +642 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test__struct.py +24 -21
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_geography.py +14 -6
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_sqlalchemy_bigquery.py +160 -106
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/conftest.py +5 -9
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test__struct.py +2 -2
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_compiler.py +132 -22
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_compliance.py +20 -30
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_geography.py +5 -5
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_select.py +46 -126
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_sqlalchemy_bigquery.py +2 -8
- sqlalchemy-bigquery-1.10.0/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +0 -291
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/LICENSE +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/MANIFEST.in +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/setup.cfg +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/__init__.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/_helpers.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/_types.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/geography.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/parse_url.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/SOURCES.txt +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/dependency_links.txt +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/entry_points.txt +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/top_level.txt +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/__init__.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/conftest.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/sqlalchemy_dialect_compliance/README.rst +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/sqlalchemy_dialect_compliance/conftest.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/__init__.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/conftest.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/data/sample.json +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/data/sample_one_row.json +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/data/schema.json +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_alembic.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_helpers.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/__init__.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/fauxdbi.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_catalog_functions.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_comments.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_dialect_types.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_engine.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_helpers.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_like_reescape.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_parse_url.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_table_options.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_version.py +0 -0
- {sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_view.py +0 -0
{sqlalchemy-bigquery-1.10.0/sqlalchemy_bigquery.egg-info → sqlalchemy-bigquery-1.11.0}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sqlalchemy-bigquery
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.0
|
|
4
4
|
Summary: SQLAlchemy dialect for BigQuery
|
|
5
5
|
Home-page: https://github.com/googleapis/python-bigquery-sqlalchemy
|
|
6
6
|
Author: The Sqlalchemy-Bigquery Authors
|
|
@@ -26,9 +26,9 @@ License-File: LICENSE
|
|
|
26
26
|
License-File: AUTHORS
|
|
27
27
|
Requires-Dist: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5
|
|
28
28
|
Requires-Dist: google-auth<3.0.0dev,>=1.25.0
|
|
29
|
-
Requires-Dist: google-cloud-bigquery<4.0.0dev,>=
|
|
29
|
+
Requires-Dist: google-cloud-bigquery<4.0.0dev,>=3.3.6
|
|
30
30
|
Requires-Dist: packaging
|
|
31
|
-
Requires-Dist: sqlalchemy<
|
|
31
|
+
Requires-Dist: sqlalchemy<3.0.0dev,>=1.4.16
|
|
32
32
|
Provides-Extra: geography
|
|
33
33
|
Requires-Dist: GeoAlchemy2; extra == "geography"
|
|
34
34
|
Requires-Dist: shapely; extra == "geography"
|
|
@@ -43,15 +43,15 @@ Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "bqstorage"
|
|
|
43
43
|
Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "bqstorage"
|
|
44
44
|
Requires-Dist: pyarrow>=3.0.0; extra == "bqstorage"
|
|
45
45
|
Provides-Extra: all
|
|
46
|
-
Requires-Dist: alembic; extra == "all"
|
|
47
|
-
Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
|
|
48
|
-
Requires-Dist: shapely; extra == "all"
|
|
49
|
-
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
50
|
-
Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "all"
|
|
51
|
-
Requires-Dist: packaging; extra == "all"
|
|
52
46
|
Requires-Dist: pytz; extra == "all"
|
|
53
|
-
Requires-Dist:
|
|
47
|
+
Requires-Dist: packaging; extra == "all"
|
|
48
|
+
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
54
49
|
Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "all"
|
|
50
|
+
Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
|
|
51
|
+
Requires-Dist: alembic; extra == "all"
|
|
52
|
+
Requires-Dist: GeoAlchemy2; extra == "all"
|
|
53
|
+
Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "all"
|
|
54
|
+
Requires-Dist: shapely; extra == "all"
|
|
55
55
|
|
|
56
56
|
SQLAlchemy Dialect for BigQuery
|
|
57
57
|
===============================
|
|
@@ -89,8 +89,6 @@ In order to use this library, you first need to go through the following steps:
|
|
|
89
89
|
.. _Enable the BigQuery Storage API.: https://console.cloud.google.com/apis/library/bigquery.googleapis.com
|
|
90
90
|
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
91
91
|
|
|
92
|
-
.. note::
|
|
93
|
-
This library is only compatible with SQLAlchemy versions < 2.0.0
|
|
94
92
|
|
|
95
93
|
Installation
|
|
96
94
|
------------
|
|
@@ -163,7 +161,8 @@ SQLAlchemy
|
|
|
163
161
|
from sqlalchemy.schema import *
|
|
164
162
|
engine = create_engine('bigquery://project')
|
|
165
163
|
table = Table('dataset.table', MetaData(bind=engine), autoload=True)
|
|
166
|
-
print(select([func.count('*')], from_obj=table).scalar())
|
|
164
|
+
print(select([func.count('*')], from_obj=table().scalar())
|
|
165
|
+
|
|
167
166
|
|
|
168
167
|
Project
|
|
169
168
|
^^^^^^^
|
|
@@ -336,7 +335,7 @@ If you need additional control, you can supply a BigQuery client of your own:
|
|
|
336
335
|
|
|
337
336
|
engine = create_engine(
|
|
338
337
|
'bigquery://some-project/some-dataset?user_supplied_client=True',
|
|
339
|
-
|
|
338
|
+
connect_args={'client': custom_bq_client},
|
|
340
339
|
)
|
|
341
340
|
|
|
342
341
|
|
|
@@ -34,8 +34,6 @@ In order to use this library, you first need to go through the following steps:
|
|
|
34
34
|
.. _Enable the BigQuery Storage API.: https://console.cloud.google.com/apis/library/bigquery.googleapis.com
|
|
35
35
|
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
36
36
|
|
|
37
|
-
.. note::
|
|
38
|
-
This library is only compatible with SQLAlchemy versions < 2.0.0
|
|
39
37
|
|
|
40
38
|
Installation
|
|
41
39
|
------------
|
|
@@ -108,7 +106,8 @@ SQLAlchemy
|
|
|
108
106
|
from sqlalchemy.schema import *
|
|
109
107
|
engine = create_engine('bigquery://project')
|
|
110
108
|
table = Table('dataset.table', MetaData(bind=engine), autoload=True)
|
|
111
|
-
print(select([func.count('*')], from_obj=table).scalar())
|
|
109
|
+
print(select([func.count('*')], from_obj=table().scalar())
|
|
110
|
+
|
|
112
111
|
|
|
113
112
|
Project
|
|
114
113
|
^^^^^^^
|
|
@@ -281,7 +280,7 @@ If you need additional control, you can supply a BigQuery client of your own:
|
|
|
281
280
|
|
|
282
281
|
engine = create_engine(
|
|
283
282
|
'bigquery://some-project/some-dataset?user_supplied_client=True',
|
|
284
|
-
|
|
283
|
+
connect_args={'client': custom_bq_client},
|
|
285
284
|
)
|
|
286
285
|
|
|
287
286
|
|
|
@@ -99,9 +99,9 @@ setup(
|
|
|
99
99
|
# Until this issue is closed
|
|
100
100
|
# https://github.com/googleapis/google-cloud-python/issues/10566
|
|
101
101
|
"google-auth>=1.25.0,<3.0.0dev", # Work around pip wack.
|
|
102
|
-
"google-cloud-bigquery>=
|
|
102
|
+
"google-cloud-bigquery>=3.3.6,<4.0.0dev",
|
|
103
103
|
"packaging",
|
|
104
|
-
"sqlalchemy>=1.
|
|
104
|
+
"sqlalchemy>=1.4.16,<3.0.0dev",
|
|
105
105
|
],
|
|
106
106
|
extras_require=extras,
|
|
107
107
|
python_requires=">=3.8, <3.13",
|
|
@@ -17,20 +17,14 @@
|
|
|
17
17
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
18
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
19
|
|
|
20
|
-
import packaging.version
|
|
21
20
|
import sqlalchemy.sql.default_comparator
|
|
22
21
|
import sqlalchemy.sql.sqltypes
|
|
23
22
|
import sqlalchemy.types
|
|
24
23
|
|
|
25
24
|
from . import base
|
|
26
25
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
) >= packaging.version.parse("1.4")
|
|
30
|
-
|
|
31
|
-
if sqlalchemy_1_4_or_more:
|
|
32
|
-
import sqlalchemy.sql.coercions
|
|
33
|
-
import sqlalchemy.sql.roles
|
|
26
|
+
import sqlalchemy.sql.coercions
|
|
27
|
+
import sqlalchemy.sql.roles
|
|
34
28
|
|
|
35
29
|
|
|
36
30
|
def _get_subtype_col_spec(type_):
|
|
@@ -103,34 +97,20 @@ class STRUCT(sqlalchemy.sql.sqltypes.Indexable, sqlalchemy.types.UserDefinedType
|
|
|
103
97
|
def __getattr__(self, name):
|
|
104
98
|
if name.lower() in self.expr.type._STRUCT_byname:
|
|
105
99
|
return self[name]
|
|
100
|
+
else:
|
|
101
|
+
raise AttributeError(name)
|
|
106
102
|
|
|
107
103
|
comparator_factory = Comparator
|
|
108
104
|
|
|
109
105
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
sqlalchemy.sql.roles.BinaryElementRole,
|
|
119
|
-
name,
|
|
120
|
-
expr=self.expr,
|
|
121
|
-
operator=operator,
|
|
122
|
-
bindparam_type=sqlalchemy.types.String(),
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
else:
|
|
126
|
-
|
|
127
|
-
def _field_index(self, name, operator):
|
|
128
|
-
return sqlalchemy.sql.default_comparator._check_literal(
|
|
129
|
-
self.expr,
|
|
130
|
-
operator,
|
|
131
|
-
name,
|
|
132
|
-
bindparam_type=sqlalchemy.types.String(),
|
|
133
|
-
)
|
|
106
|
+
def _field_index(self, name, operator):
|
|
107
|
+
return sqlalchemy.sql.coercions.expect(
|
|
108
|
+
sqlalchemy.sql.roles.BinaryElementRole,
|
|
109
|
+
name,
|
|
110
|
+
expr=self.expr,
|
|
111
|
+
operator=operator,
|
|
112
|
+
bindparam_type=sqlalchemy.types.String(),
|
|
113
|
+
)
|
|
134
114
|
|
|
135
115
|
|
|
136
116
|
def struct_getitem_op(a, b):
|
|
@@ -163,7 +163,7 @@ class BigQueryExecutionContext(DefaultExecutionContext):
|
|
|
163
163
|
""",
|
|
164
164
|
flags=re.IGNORECASE | re.VERBOSE,
|
|
165
165
|
)
|
|
166
|
-
def __distribute_types_to_expanded_placeholders(self, m):
|
|
166
|
+
def __distribute_types_to_expanded_placeholders(self, m): # pragma: NO COVER
|
|
167
167
|
# If we have an in parameter, it sometimes gets expaned to 0 or more
|
|
168
168
|
# parameters and we need to move the type marker to each
|
|
169
169
|
# parameter.
|
|
@@ -174,6 +174,8 @@ class BigQueryExecutionContext(DefaultExecutionContext):
|
|
|
174
174
|
# suffixes refect that when an array parameter is expanded,
|
|
175
175
|
# numeric suffixes are added. For example, a placeholder like
|
|
176
176
|
# `%(foo)s` gets expaneded to `%(foo_0)s, `%(foo_1)s, ...`.
|
|
177
|
+
|
|
178
|
+
# Coverage: despite our best efforts, never recognized this segment of code as being tested.
|
|
177
179
|
placeholders, type_ = m.groups()
|
|
178
180
|
if placeholders:
|
|
179
181
|
placeholders = placeholders.replace(")", f":{type_})")
|
|
@@ -219,7 +221,7 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
219
221
|
# For example, given SQLAlchemy code:
|
|
220
222
|
#
|
|
221
223
|
# print(
|
|
222
|
-
# select(
|
|
224
|
+
# select(func.unnest(foo.c.objects).alias('foo_objects').column)
|
|
223
225
|
# .compile(engine))
|
|
224
226
|
#
|
|
225
227
|
# Left to it's own devices, SQLAlchemy would outout:
|
|
@@ -336,7 +338,14 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
336
338
|
# Flag set in the group_by_clause method. Works around missing
|
|
337
339
|
# equivalent to supports_simple_order_by_label for group by.
|
|
338
340
|
if within_group_by:
|
|
339
|
-
|
|
341
|
+
column_label = args[0]
|
|
342
|
+
sql_keywords = {"GROUPING SETS", "ROLLUP", "CUBE"}
|
|
343
|
+
for keyword in sql_keywords:
|
|
344
|
+
if keyword in str(column_label):
|
|
345
|
+
break
|
|
346
|
+
else: # for/else always happens unless break gets called
|
|
347
|
+
kwargs["render_label_as_label"] = column_label
|
|
348
|
+
|
|
340
349
|
return super(BigQueryCompiler, self).visit_label(*args, **kwargs)
|
|
341
350
|
|
|
342
351
|
def group_by_clause(self, select, **kw):
|
|
@@ -356,11 +365,7 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
356
365
|
|
|
357
366
|
__sqlalchemy_version_info = packaging.version.parse(sqlalchemy.__version__)
|
|
358
367
|
|
|
359
|
-
__expanding_text =
|
|
360
|
-
"EXPANDING"
|
|
361
|
-
if __sqlalchemy_version_info < packaging.version.parse("1.4")
|
|
362
|
-
else "POSTCOMPILE"
|
|
363
|
-
)
|
|
368
|
+
__expanding_text = "POSTCOMPILE"
|
|
364
369
|
|
|
365
370
|
# https://github.com/sqlalchemy/sqlalchemy/commit/f79df12bd6d99b8f6f09d4bf07722638c4b4c159
|
|
366
371
|
__expanding_conflict = (
|
|
@@ -388,9 +393,6 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
388
393
|
self._generate_generic_binary(binary, " IN ", **kw)
|
|
389
394
|
)
|
|
390
395
|
|
|
391
|
-
def visit_empty_set_expr(self, element_types):
|
|
392
|
-
return ""
|
|
393
|
-
|
|
394
396
|
def visit_not_in_op_binary(self, binary, operator, **kw):
|
|
395
397
|
return (
|
|
396
398
|
"("
|
|
@@ -400,8 +402,6 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
400
402
|
+ ")"
|
|
401
403
|
)
|
|
402
404
|
|
|
403
|
-
visit_notin_op_binary = visit_not_in_op_binary # before 1.4
|
|
404
|
-
|
|
405
405
|
############################################################################
|
|
406
406
|
|
|
407
407
|
############################################################################
|
|
@@ -424,8 +424,8 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
424
424
|
self._maybe_reescape(binary), operator, **kw
|
|
425
425
|
)
|
|
426
426
|
|
|
427
|
-
def
|
|
428
|
-
return super(BigQueryCompiler, self).
|
|
427
|
+
def visit_not_contains_op_binary(self, binary, operator, **kw):
|
|
428
|
+
return super(BigQueryCompiler, self).visit_not_contains_op_binary(
|
|
429
429
|
self._maybe_reescape(binary), operator, **kw
|
|
430
430
|
)
|
|
431
431
|
|
|
@@ -434,8 +434,8 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
434
434
|
self._maybe_reescape(binary), operator, **kw
|
|
435
435
|
)
|
|
436
436
|
|
|
437
|
-
def
|
|
438
|
-
return super(BigQueryCompiler, self).
|
|
437
|
+
def visit_not_startswith_op_binary(self, binary, operator, **kw):
|
|
438
|
+
return super(BigQueryCompiler, self).visit_not_startswith_op_binary(
|
|
439
439
|
self._maybe_reescape(binary), operator, **kw
|
|
440
440
|
)
|
|
441
441
|
|
|
@@ -444,8 +444,8 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
444
444
|
self._maybe_reescape(binary), operator, **kw
|
|
445
445
|
)
|
|
446
446
|
|
|
447
|
-
def
|
|
448
|
-
return super(BigQueryCompiler, self).
|
|
447
|
+
def visit_not_endswith_op_binary(self, binary, operator, **kw):
|
|
448
|
+
return super(BigQueryCompiler, self).visit_not_endswith_op_binary(
|
|
449
449
|
self._maybe_reescape(binary), operator, **kw
|
|
450
450
|
)
|
|
451
451
|
|
|
@@ -510,7 +510,8 @@ class BigQueryCompiler(_struct.SQLCompiler, SQLCompiler):
|
|
|
510
510
|
# here, because then we can't do a recompile later (e.g., first
|
|
511
511
|
# print the statment, then execute it). See issue #357.
|
|
512
512
|
#
|
|
513
|
-
|
|
513
|
+
# Coverage: despite our best efforts, never recognized this segment of code as being tested.
|
|
514
|
+
if getattr(bindparam, "expand_op", None) is not None: # pragma: NO COVER
|
|
514
515
|
assert bindparam.expand_op.__name__.endswith("in_op") # in in
|
|
515
516
|
bindparam = bindparam._clone(maintain_key=True)
|
|
516
517
|
bindparam.expanding = False
|
|
@@ -644,15 +645,15 @@ class BigQueryDDLCompiler(DDLCompiler):
|
|
|
644
645
|
}
|
|
645
646
|
|
|
646
647
|
# BigQuery has no support for foreign keys.
|
|
647
|
-
def visit_foreign_key_constraint(self, constraint):
|
|
648
|
+
def visit_foreign_key_constraint(self, constraint, **kw):
|
|
648
649
|
return None
|
|
649
650
|
|
|
650
651
|
# BigQuery has no support for primary keys.
|
|
651
|
-
def visit_primary_key_constraint(self, constraint):
|
|
652
|
+
def visit_primary_key_constraint(self, constraint, **kw):
|
|
652
653
|
return None
|
|
653
654
|
|
|
654
655
|
# BigQuery has no support for unique constraints.
|
|
655
|
-
def visit_unique_constraint(self, constraint):
|
|
656
|
+
def visit_unique_constraint(self, constraint, **kw):
|
|
656
657
|
return None
|
|
657
658
|
|
|
658
659
|
def get_column_specification(self, column, **kwargs):
|
|
@@ -760,14 +761,14 @@ class BigQueryDDLCompiler(DDLCompiler):
|
|
|
760
761
|
|
|
761
762
|
return " " + "\n".join(clauses)
|
|
762
763
|
|
|
763
|
-
def visit_set_table_comment(self, create):
|
|
764
|
+
def visit_set_table_comment(self, create, **kw):
|
|
764
765
|
table_name = self.preparer.format_table(create.element)
|
|
765
766
|
description = self.sql_compiler.render_literal_value(
|
|
766
767
|
create.element.comment, sqlalchemy.sql.sqltypes.String()
|
|
767
768
|
)
|
|
768
769
|
return f"ALTER TABLE {table_name} SET OPTIONS(description={description})"
|
|
769
770
|
|
|
770
|
-
def visit_drop_table_comment(self, drop):
|
|
771
|
+
def visit_drop_table_comment(self, drop, **kw):
|
|
771
772
|
table_name = self.preparer.format_table(drop.element)
|
|
772
773
|
return f"ALTER TABLE {table_name} SET OPTIONS(description=null)"
|
|
773
774
|
|
|
@@ -1030,6 +1031,14 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1030
1031
|
|
|
1031
1032
|
@classmethod
|
|
1032
1033
|
def dbapi(cls):
|
|
1034
|
+
"""
|
|
1035
|
+
Use `import_dbapi()` instead.
|
|
1036
|
+
Maintained for backward compatibility.
|
|
1037
|
+
"""
|
|
1038
|
+
return dbapi
|
|
1039
|
+
|
|
1040
|
+
@classmethod
|
|
1041
|
+
def import_dbapi(cls):
|
|
1033
1042
|
return dbapi
|
|
1034
1043
|
|
|
1035
1044
|
@staticmethod
|
|
@@ -1202,7 +1211,21 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1202
1211
|
raise NoSuchTableError(table_name)
|
|
1203
1212
|
return table
|
|
1204
1213
|
|
|
1205
|
-
def has_table(self, connection, table_name, schema=None):
|
|
1214
|
+
def has_table(self, connection, table_name, schema=None, **kw):
|
|
1215
|
+
"""Checks whether a table exists in BigQuery.
|
|
1216
|
+
|
|
1217
|
+
Args:
|
|
1218
|
+
connection (google.cloud.bigquery.client.Client): The client
|
|
1219
|
+
object used to interact with BigQuery.
|
|
1220
|
+
table_name (str): The name of the table to check for.
|
|
1221
|
+
schema (str, optional): The name of the schema to which the table
|
|
1222
|
+
belongs. Defaults to the default schema.
|
|
1223
|
+
**kw (dict): Any extra keyword arguments will be ignored.
|
|
1224
|
+
|
|
1225
|
+
Returns:
|
|
1226
|
+
bool: True if the table exists, False otherwise.
|
|
1227
|
+
|
|
1228
|
+
"""
|
|
1206
1229
|
try:
|
|
1207
1230
|
self._get_table(connection, table_name, schema)
|
|
1208
1231
|
return True
|
|
@@ -1256,10 +1279,6 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1256
1279
|
# BigQuery has no support for transactions.
|
|
1257
1280
|
pass
|
|
1258
1281
|
|
|
1259
|
-
def _check_unicode_returns(self, connection, additional_tests=None):
|
|
1260
|
-
# requests gives back Unicode strings
|
|
1261
|
-
return True
|
|
1262
|
-
|
|
1263
1282
|
def get_view_definition(self, connection, view_name, schema=None, **kw):
|
|
1264
1283
|
if isinstance(connection, Engine):
|
|
1265
1284
|
connection = connection.connect()
|
|
@@ -1279,7 +1298,13 @@ class unnest(sqlalchemy.sql.functions.GenericFunction):
|
|
|
1279
1298
|
raise TypeError("The unnest function requires a single argument.")
|
|
1280
1299
|
arg = args[0]
|
|
1281
1300
|
if isinstance(arg, sqlalchemy.sql.expression.ColumnElement):
|
|
1282
|
-
if not
|
|
1301
|
+
if not (
|
|
1302
|
+
isinstance(arg.type, sqlalchemy.sql.sqltypes.ARRAY)
|
|
1303
|
+
or (
|
|
1304
|
+
hasattr(arg.type, "impl")
|
|
1305
|
+
and isinstance(arg.type.impl, sqlalchemy.sql.sqltypes.ARRAY)
|
|
1306
|
+
)
|
|
1307
|
+
):
|
|
1283
1308
|
raise TypeError("The argument to unnest must have an ARRAY type.")
|
|
1284
1309
|
self.type = arg.type.item_type
|
|
1285
1310
|
super().__init__(*args, **kwargs)
|
{sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/requirements.py
RENAMED
|
@@ -136,6 +136,11 @@ class Requirements(sqlalchemy.testing.requirements.SuiteRequirements):
|
|
|
136
136
|
|
|
137
137
|
return unsupported()
|
|
138
138
|
|
|
139
|
+
@property
|
|
140
|
+
def array_type(self):
|
|
141
|
+
"""Target database must support array_type"""
|
|
142
|
+
return supported()
|
|
143
|
+
|
|
139
144
|
@property
|
|
140
145
|
def implicit_default_schema(self):
|
|
141
146
|
"""target system has a strong concept of 'default' schema that can
|
{sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0/sqlalchemy_bigquery.egg-info}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: sqlalchemy-bigquery
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.11.0
|
|
4
4
|
Summary: SQLAlchemy dialect for BigQuery
|
|
5
5
|
Home-page: https://github.com/googleapis/python-bigquery-sqlalchemy
|
|
6
6
|
Author: The Sqlalchemy-Bigquery Authors
|
|
@@ -26,9 +26,9 @@ License-File: LICENSE
|
|
|
26
26
|
License-File: AUTHORS
|
|
27
27
|
Requires-Dist: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5
|
|
28
28
|
Requires-Dist: google-auth<3.0.0dev,>=1.25.0
|
|
29
|
-
Requires-Dist: google-cloud-bigquery<4.0.0dev,>=
|
|
29
|
+
Requires-Dist: google-cloud-bigquery<4.0.0dev,>=3.3.6
|
|
30
30
|
Requires-Dist: packaging
|
|
31
|
-
Requires-Dist: sqlalchemy<
|
|
31
|
+
Requires-Dist: sqlalchemy<3.0.0dev,>=1.4.16
|
|
32
32
|
Provides-Extra: geography
|
|
33
33
|
Requires-Dist: GeoAlchemy2; extra == "geography"
|
|
34
34
|
Requires-Dist: shapely; extra == "geography"
|
|
@@ -43,15 +43,15 @@ Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "bqstorage"
|
|
|
43
43
|
Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "bqstorage"
|
|
44
44
|
Requires-Dist: pyarrow>=3.0.0; extra == "bqstorage"
|
|
45
45
|
Provides-Extra: all
|
|
46
|
-
Requires-Dist: alembic; extra == "all"
|
|
47
|
-
Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
|
|
48
|
-
Requires-Dist: shapely; extra == "all"
|
|
49
|
-
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
50
|
-
Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "all"
|
|
51
|
-
Requires-Dist: packaging; extra == "all"
|
|
52
46
|
Requires-Dist: pytz; extra == "all"
|
|
53
|
-
Requires-Dist:
|
|
47
|
+
Requires-Dist: packaging; extra == "all"
|
|
48
|
+
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
54
49
|
Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "all"
|
|
50
|
+
Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
|
|
51
|
+
Requires-Dist: alembic; extra == "all"
|
|
52
|
+
Requires-Dist: GeoAlchemy2; extra == "all"
|
|
53
|
+
Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "all"
|
|
54
|
+
Requires-Dist: shapely; extra == "all"
|
|
55
55
|
|
|
56
56
|
SQLAlchemy Dialect for BigQuery
|
|
57
57
|
===============================
|
|
@@ -89,8 +89,6 @@ In order to use this library, you first need to go through the following steps:
|
|
|
89
89
|
.. _Enable the BigQuery Storage API.: https://console.cloud.google.com/apis/library/bigquery.googleapis.com
|
|
90
90
|
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
|
|
91
91
|
|
|
92
|
-
.. note::
|
|
93
|
-
This library is only compatible with SQLAlchemy versions < 2.0.0
|
|
94
92
|
|
|
95
93
|
Installation
|
|
96
94
|
------------
|
|
@@ -163,7 +161,8 @@ SQLAlchemy
|
|
|
163
161
|
from sqlalchemy.schema import *
|
|
164
162
|
engine = create_engine('bigquery://project')
|
|
165
163
|
table = Table('dataset.table', MetaData(bind=engine), autoload=True)
|
|
166
|
-
print(select([func.count('*')], from_obj=table).scalar())
|
|
164
|
+
print(select([func.count('*')], from_obj=table().scalar())
|
|
165
|
+
|
|
167
166
|
|
|
168
167
|
Project
|
|
169
168
|
^^^^^^^
|
|
@@ -336,7 +335,7 @@ If you need additional control, you can supply a BigQuery client of your own:
|
|
|
336
335
|
|
|
337
336
|
engine = create_engine(
|
|
338
337
|
'bigquery://some-project/some-dataset?user_supplied_client=True',
|
|
339
|
-
|
|
338
|
+
connect_args={'client': custom_bq_client},
|
|
340
339
|
)
|
|
341
340
|
|
|
342
341
|
|
{sqlalchemy-bigquery-1.10.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/requires.txt
RENAMED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5
|
|
2
2
|
google-auth<3.0.0dev,>=1.25.0
|
|
3
|
-
google-cloud-bigquery<4.0.0dev,>=
|
|
3
|
+
google-cloud-bigquery<4.0.0dev,>=3.3.6
|
|
4
4
|
packaging
|
|
5
|
-
sqlalchemy<
|
|
5
|
+
sqlalchemy<3.0.0dev,>=1.4.16
|
|
6
6
|
|
|
7
7
|
[alembic]
|
|
8
8
|
alembic
|
|
9
9
|
|
|
10
10
|
[all]
|
|
11
|
-
alembic
|
|
12
|
-
google-cloud-bigquery-storage<3.0.0dev,>=2.0.0
|
|
13
|
-
shapely
|
|
14
|
-
pyarrow>=3.0.0
|
|
15
|
-
packaging
|
|
16
11
|
pytz
|
|
17
|
-
|
|
12
|
+
packaging
|
|
13
|
+
pyarrow>=3.0.0
|
|
18
14
|
grpcio<2.0dev,>=1.47.0
|
|
15
|
+
google-cloud-bigquery-storage<3.0.0dev,>=2.0.0
|
|
16
|
+
alembic
|
|
17
|
+
GeoAlchemy2
|
|
18
|
+
shapely
|
|
19
19
|
|
|
20
20
|
[all:python_version >= "3.11"]
|
|
21
21
|
grpcio<2.0dev,>=1.49.1
|