sqlalchemy-bigquery 1.13.0__tar.gz → 1.14.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.13.0/sqlalchemy_bigquery.egg-info → sqlalchemy_bigquery-1.14.0}/PKG-INFO +5 -5
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/setup.cfg +0 -3
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/base.py +31 -17
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/version.py +1 -1
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0/sqlalchemy_bigquery.egg-info}/PKG-INFO +5 -5
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/SOURCES.txt +1 -0
- sqlalchemy_bigquery-1.14.0/tests/system/test_sqlalchemy_bigquery_remote.py +107 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/fauxdbi.py +13 -8
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_engine.py +6 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/AUTHORS +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/LICENSE +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/MANIFEST.in +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/README.rst +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/pyproject.toml +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/setup.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/__init__.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/_helpers.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/_struct.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/_types.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/_versions_helpers.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/geography.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/parse_url.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/requirements.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/dependency_links.txt +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/entry_points.txt +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/requires.txt +4 -4
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/top_level.txt +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/__init__.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/conftest.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/sqlalchemy_dialect_compliance/README.rst +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/sqlalchemy_dialect_compliance/conftest.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/__init__.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/conftest.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/data/sample.json +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/data/sample_one_row.json +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/data/schema.json +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/test__struct.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/test_alembic.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/test_geography.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/test_helpers.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/test_sqlalchemy_bigquery.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/__init__.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/conftest.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test__struct.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_alembic.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_catalog_functions.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_comments.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_compiler.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_compliance.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_dialect_types.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_geography.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_helpers.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_like_reescape.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_parse_url.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_select.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_sqlalchemy_bigquery.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_table_options.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_version.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_view.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/third_party/sqlalchemy_bigquery_vendored/__init__.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/third_party/sqlalchemy_bigquery_vendored/py.typed +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/AUTHORS +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/LICENSE +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/__init__.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/postgresql/__init__.py +0 -0
- {sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/postgresql/base.py +0 -0
{sqlalchemy_bigquery-1.13.0/sqlalchemy_bigquery.egg-info → sqlalchemy_bigquery-1.14.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.14.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
|
|
@@ -43,15 +43,15 @@ Requires-Dist: grpcio<2.0.0,>=1.47.0; extra == "bqstorage"
|
|
|
43
43
|
Requires-Dist: grpcio<2.0.0,>=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: grpcio<2.0.0,>=1.47.0; extra == "all"
|
|
47
46
|
Requires-Dist: GeoAlchemy2; extra == "all"
|
|
48
|
-
Requires-Dist:
|
|
47
|
+
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
48
|
+
Requires-Dist: grpcio<2.0.0,>=1.47.0; extra == "all"
|
|
49
49
|
Requires-Dist: shapely; extra == "all"
|
|
50
|
-
Requires-Dist:
|
|
50
|
+
Requires-Dist: alembic; extra == "all"
|
|
51
51
|
Requires-Dist: packaging; extra == "all"
|
|
52
52
|
Requires-Dist: google-cloud-bigquery-storage<3.0.0,>=2.0.0; extra == "all"
|
|
53
|
+
Requires-Dist: pytz; extra == "all"
|
|
53
54
|
Requires-Dist: grpcio<2.0.0,>=1.49.1; python_version >= "3.11" and extra == "all"
|
|
54
|
-
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
55
55
|
|
|
56
56
|
SQLAlchemy Dialect for BigQuery
|
|
57
57
|
===============================
|
|
@@ -27,7 +27,7 @@ import uuid
|
|
|
27
27
|
|
|
28
28
|
from google import auth
|
|
29
29
|
import google.api_core.exceptions
|
|
30
|
-
from google.cloud.bigquery import dbapi
|
|
30
|
+
from google.cloud.bigquery import dbapi, ConnectionProperty
|
|
31
31
|
from google.cloud.bigquery.table import (
|
|
32
32
|
RangePartitioning,
|
|
33
33
|
TableReference,
|
|
@@ -61,6 +61,7 @@ import re
|
|
|
61
61
|
from .parse_url import parse_url
|
|
62
62
|
from . import _helpers, _struct, _types
|
|
63
63
|
import sqlalchemy_bigquery_vendored.sqlalchemy.postgresql.base as vendored_postgresql
|
|
64
|
+
from google.cloud.bigquery import QueryJobConfig
|
|
64
65
|
|
|
65
66
|
# Illegal characters is intended to be all characters that are not explicitly
|
|
66
67
|
# allowed as part of the flexible column names.
|
|
@@ -1080,6 +1081,7 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1080
1081
|
self,
|
|
1081
1082
|
arraysize=5000,
|
|
1082
1083
|
credentials_path=None,
|
|
1084
|
+
billing_project_id=None,
|
|
1083
1085
|
location=None,
|
|
1084
1086
|
credentials_info=None,
|
|
1085
1087
|
credentials_base64=None,
|
|
@@ -1092,6 +1094,8 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1092
1094
|
self.credentials_path = credentials_path
|
|
1093
1095
|
self.credentials_info = credentials_info
|
|
1094
1096
|
self.credentials_base64 = credentials_base64
|
|
1097
|
+
self.project_id = None
|
|
1098
|
+
self.billing_project_id = billing_project_id
|
|
1095
1099
|
self.location = location
|
|
1096
1100
|
self.identifier_preparer = self.preparer(self)
|
|
1097
1101
|
self.dataset_id = None
|
|
@@ -1114,15 +1118,20 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1114
1118
|
"""Build '<dataset_id>.<table_id>' string using given table."""
|
|
1115
1119
|
return "{}.{}".format(table.reference.dataset_id, table.table_id)
|
|
1116
1120
|
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1121
|
+
def create_job_config(self, provided_config: QueryJobConfig):
|
|
1122
|
+
project_id = self.project_id
|
|
1123
|
+
if self.dataset_id is None and project_id == self.billing_project_id:
|
|
1124
|
+
return provided_config
|
|
1125
|
+
job_config = provided_config or QueryJobConfig()
|
|
1126
|
+
if project_id != self.billing_project_id:
|
|
1127
|
+
job_config.connection_properties = [
|
|
1128
|
+
ConnectionProperty(key="dataset_project_id", value=project_id)
|
|
1129
|
+
]
|
|
1130
|
+
if self.dataset_id:
|
|
1122
1131
|
if not project_id:
|
|
1123
1132
|
_, project_id = auth.default()
|
|
1124
|
-
|
|
1125
|
-
|
|
1133
|
+
job_config.default_dataset = "{}.{}".format(project_id, self.dataset_id)
|
|
1134
|
+
return job_config
|
|
1126
1135
|
|
|
1127
1136
|
def do_execute(self, cursor, statement, parameters, context=None):
|
|
1128
1137
|
kwargs = {}
|
|
@@ -1132,13 +1141,13 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1132
1141
|
|
|
1133
1142
|
def create_connect_args(self, url):
|
|
1134
1143
|
(
|
|
1135
|
-
project_id,
|
|
1144
|
+
self.project_id,
|
|
1136
1145
|
location,
|
|
1137
1146
|
dataset_id,
|
|
1138
1147
|
arraysize,
|
|
1139
1148
|
credentials_path,
|
|
1140
1149
|
credentials_base64,
|
|
1141
|
-
|
|
1150
|
+
provided_job_config,
|
|
1142
1151
|
list_tables_page_size,
|
|
1143
1152
|
user_supplied_client,
|
|
1144
1153
|
) = parse_url(url)
|
|
@@ -1149,9 +1158,9 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1149
1158
|
self.credentials_path = credentials_path or self.credentials_path
|
|
1150
1159
|
self.credentials_base64 = credentials_base64 or self.credentials_base64
|
|
1151
1160
|
self.dataset_id = dataset_id
|
|
1152
|
-
self.
|
|
1153
|
-
|
|
1154
|
-
)
|
|
1161
|
+
self.billing_project_id = self.billing_project_id or self.project_id
|
|
1162
|
+
|
|
1163
|
+
default_query_job_config = self.create_job_config(provided_job_config)
|
|
1155
1164
|
|
|
1156
1165
|
if user_supplied_client:
|
|
1157
1166
|
# The user is expected to supply a client with
|
|
@@ -1162,10 +1171,14 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1162
1171
|
credentials_path=self.credentials_path,
|
|
1163
1172
|
credentials_info=self.credentials_info,
|
|
1164
1173
|
credentials_base64=self.credentials_base64,
|
|
1165
|
-
project_id=
|
|
1174
|
+
project_id=self.billing_project_id,
|
|
1166
1175
|
location=self.location,
|
|
1167
1176
|
default_query_job_config=default_query_job_config,
|
|
1168
1177
|
)
|
|
1178
|
+
# If the user specified `bigquery://` we need to set the project_id
|
|
1179
|
+
# from the client
|
|
1180
|
+
self.project_id = self.project_id or client.project
|
|
1181
|
+
self.billing_project_id = self.billing_project_id or client.project
|
|
1169
1182
|
return ([], {"client": client})
|
|
1170
1183
|
|
|
1171
1184
|
def _get_table_or_view_names(self, connection, item_types, schema=None):
|
|
@@ -1177,7 +1190,7 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1177
1190
|
)
|
|
1178
1191
|
|
|
1179
1192
|
client = connection.connection._client
|
|
1180
|
-
datasets = client.list_datasets()
|
|
1193
|
+
datasets = client.list_datasets(self.project_id)
|
|
1181
1194
|
|
|
1182
1195
|
result = []
|
|
1183
1196
|
for dataset in datasets:
|
|
@@ -1278,7 +1291,8 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1278
1291
|
|
|
1279
1292
|
client = connection.connection._client
|
|
1280
1293
|
|
|
1281
|
-
table_ref = self._table_reference(schema, table_name, client.project)
|
|
1294
|
+
# table_ref = self._table_reference(schema, table_name, client.project)
|
|
1295
|
+
table_ref = self._table_reference(schema, table_name, self.project_id)
|
|
1282
1296
|
try:
|
|
1283
1297
|
table = client.get_table(table_ref)
|
|
1284
1298
|
except NotFound:
|
|
@@ -1332,7 +1346,7 @@ class BigQueryDialect(DefaultDialect):
|
|
|
1332
1346
|
if isinstance(connection, Engine):
|
|
1333
1347
|
connection = connection.connect()
|
|
1334
1348
|
|
|
1335
|
-
datasets = connection.connection._client.list_datasets()
|
|
1349
|
+
datasets = connection.connection._client.list_datasets(self.project_id)
|
|
1336
1350
|
return [d.dataset_id for d in datasets]
|
|
1337
1351
|
|
|
1338
1352
|
def get_table_names(self, connection, schema=None, **kw):
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.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.14.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
|
|
@@ -43,15 +43,15 @@ Requires-Dist: grpcio<2.0.0,>=1.47.0; extra == "bqstorage"
|
|
|
43
43
|
Requires-Dist: grpcio<2.0.0,>=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: grpcio<2.0.0,>=1.47.0; extra == "all"
|
|
47
46
|
Requires-Dist: GeoAlchemy2; extra == "all"
|
|
48
|
-
Requires-Dist:
|
|
47
|
+
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
48
|
+
Requires-Dist: grpcio<2.0.0,>=1.47.0; extra == "all"
|
|
49
49
|
Requires-Dist: shapely; extra == "all"
|
|
50
|
-
Requires-Dist:
|
|
50
|
+
Requires-Dist: alembic; extra == "all"
|
|
51
51
|
Requires-Dist: packaging; extra == "all"
|
|
52
52
|
Requires-Dist: google-cloud-bigquery-storage<3.0.0,>=2.0.0; extra == "all"
|
|
53
|
+
Requires-Dist: pytz; extra == "all"
|
|
53
54
|
Requires-Dist: grpcio<2.0.0,>=1.49.1; python_version >= "3.11" and extra == "all"
|
|
54
|
-
Requires-Dist: pyarrow>=3.0.0; extra == "all"
|
|
55
55
|
|
|
56
56
|
SQLAlchemy Dialect for BigQuery
|
|
57
57
|
===============================
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/SOURCES.txt
RENAMED
|
@@ -33,6 +33,7 @@ tests/system/test_alembic.py
|
|
|
33
33
|
tests/system/test_geography.py
|
|
34
34
|
tests/system/test_helpers.py
|
|
35
35
|
tests/system/test_sqlalchemy_bigquery.py
|
|
36
|
+
tests/system/test_sqlalchemy_bigquery_remote.py
|
|
36
37
|
tests/system/data/sample.json
|
|
37
38
|
tests/system/data/sample_one_row.json
|
|
38
39
|
tests/system/data/schema.json
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Copyright (c) 2017 The sqlalchemy-bigquery Authors
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
# this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
# the Software without restriction, including without limitation the rights to
|
|
6
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
7
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
|
8
|
+
# subject to the following conditions:
|
|
9
|
+
#
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
# copies or substantial portions of the Software.
|
|
12
|
+
#
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
15
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
|
+
|
|
20
|
+
# -*- coding: utf-8 -*-
|
|
21
|
+
|
|
22
|
+
from sqlalchemy.engine import create_engine
|
|
23
|
+
from sqlalchemy.exc import DatabaseError
|
|
24
|
+
from sqlalchemy.schema import Table, MetaData
|
|
25
|
+
import pytest
|
|
26
|
+
import sqlalchemy
|
|
27
|
+
import google.api_core.exceptions as core_exceptions
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
EXPECTED_STATES = ["AL", "CA", "FL", "KY"]
|
|
31
|
+
|
|
32
|
+
REMOTE_TESTS = [
|
|
33
|
+
("bigquery-public-data", "bigquery-public-data.usa_names.usa_1910_2013"),
|
|
34
|
+
("bigquery-public-data", "usa_names.usa_1910_2013"),
|
|
35
|
+
("bigquery-public-data/usa_names", "bigquery-public-data.usa_names.usa_1910_2013"),
|
|
36
|
+
("bigquery-public-data/usa_names", "usa_1910_2013"),
|
|
37
|
+
("bigquery-public-data/usa_names", "usa_names.usa_1910_2013"),
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@pytest.fixture(scope="session")
|
|
42
|
+
def engine_using_remote_dataset(bigquery_client):
|
|
43
|
+
engine = create_engine(
|
|
44
|
+
"bigquery://bigquery-public-data/usa_names",
|
|
45
|
+
billing_project_id=bigquery_client.project,
|
|
46
|
+
echo=True,
|
|
47
|
+
)
|
|
48
|
+
return engine
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_remote_tables_list(engine_using_remote_dataset):
|
|
52
|
+
tables = sqlalchemy.inspect(engine_using_remote_dataset).get_table_names()
|
|
53
|
+
assert "usa_1910_2013" in tables
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@pytest.mark.parametrize(
|
|
57
|
+
["urlpath", "table_name"],
|
|
58
|
+
REMOTE_TESTS,
|
|
59
|
+
ids=[f"test_engine_remote_sql_{x}" for x in range(len(REMOTE_TESTS))],
|
|
60
|
+
)
|
|
61
|
+
def test_engine_remote_sql(bigquery_client, urlpath, table_name):
|
|
62
|
+
engine = create_engine(
|
|
63
|
+
f"bigquery://{urlpath}", billing_project_id=bigquery_client.project, echo=True
|
|
64
|
+
)
|
|
65
|
+
with engine.connect() as conn:
|
|
66
|
+
rows = conn.execute(
|
|
67
|
+
sqlalchemy.text(f"SELECT DISTINCT(state) FROM `{table_name}`")
|
|
68
|
+
).fetchall()
|
|
69
|
+
states = set(map(lambda row: row[0], rows))
|
|
70
|
+
assert set(EXPECTED_STATES).issubset(states)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@pytest.mark.parametrize(
|
|
74
|
+
["urlpath", "table_name"],
|
|
75
|
+
REMOTE_TESTS,
|
|
76
|
+
ids=[f"test_engine_remote_table_{x}" for x in range(len(REMOTE_TESTS))],
|
|
77
|
+
)
|
|
78
|
+
def test_engine_remote_table(bigquery_client, urlpath, table_name):
|
|
79
|
+
engine = create_engine(
|
|
80
|
+
f"bigquery://{urlpath}", billing_project_id=bigquery_client.project, echo=True
|
|
81
|
+
)
|
|
82
|
+
with engine.connect() as conn:
|
|
83
|
+
table = Table(table_name, MetaData(), autoload_with=engine)
|
|
84
|
+
prepared = sqlalchemy.select(
|
|
85
|
+
sqlalchemy.distinct(table.c.state)
|
|
86
|
+
).set_label_style(sqlalchemy.LABEL_STYLE_TABLENAME_PLUS_COL)
|
|
87
|
+
rows = conn.execute(prepared).fetchall()
|
|
88
|
+
states = set(map(lambda row: row[0], rows))
|
|
89
|
+
assert set(EXPECTED_STATES).issubset(states)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@pytest.mark.parametrize(
|
|
93
|
+
["urlpath", "table_name"],
|
|
94
|
+
REMOTE_TESTS,
|
|
95
|
+
ids=[f"test_engine_remote_table_fail_{x}" for x in range(len(REMOTE_TESTS))],
|
|
96
|
+
)
|
|
97
|
+
def test_engine_remote_table_fail(urlpath, table_name):
|
|
98
|
+
engine = create_engine(f"bigquery://{urlpath}", echo=True)
|
|
99
|
+
with pytest.raises(
|
|
100
|
+
(DatabaseError, core_exceptions.Forbidden), match="Access Denied"
|
|
101
|
+
):
|
|
102
|
+
with engine.connect() as conn:
|
|
103
|
+
table = Table(table_name, MetaData(), autoload_with=engine)
|
|
104
|
+
prepared = sqlalchemy.select(
|
|
105
|
+
sqlalchemy.distinct(table.c.state)
|
|
106
|
+
).set_label_style(sqlalchemy.LABEL_STYLE_TABLENAME_PLUS_COL)
|
|
107
|
+
conn.execute(prepared).fetchall()
|
|
@@ -327,10 +327,12 @@ class Cursor:
|
|
|
327
327
|
pickle.loads(v.encode("latin1"))
|
|
328
328
|
# \x80\x04 is latin-1 encoded prefix for Pickle protocol 4.
|
|
329
329
|
if isinstance(v, str) and v[:2] == "\x80\x04" and v[-1] == "."
|
|
330
|
-
else
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
330
|
+
else (
|
|
331
|
+
pickle.loads(base64.b16decode(v))
|
|
332
|
+
# 8004 is base64 encoded prefix for Pickle protocol 4.
|
|
333
|
+
if isinstance(v, str) and v[:4] == "8004" and v[-2:] == "2E"
|
|
334
|
+
else v
|
|
335
|
+
)
|
|
334
336
|
)
|
|
335
337
|
for d, v in zip(self.description, row)
|
|
336
338
|
]
|
|
@@ -355,7 +357,10 @@ class attrdict(dict):
|
|
|
355
357
|
class FauxClient:
|
|
356
358
|
def __init__(self, project_id=None, default_query_job_config=None, *args, **kw):
|
|
357
359
|
if project_id is None:
|
|
358
|
-
if
|
|
360
|
+
if (
|
|
361
|
+
default_query_job_config is not None
|
|
362
|
+
and default_query_job_config.default_dataset
|
|
363
|
+
):
|
|
359
364
|
project_id = default_query_job_config.default_dataset.project
|
|
360
365
|
else:
|
|
361
366
|
project_id = "authproj" # we would still have gotten it from auth.
|
|
@@ -469,10 +474,10 @@ class FauxClient:
|
|
|
469
474
|
else:
|
|
470
475
|
raise google.api_core.exceptions.NotFound(table_ref)
|
|
471
476
|
|
|
472
|
-
def list_datasets(self):
|
|
477
|
+
def list_datasets(self, project="myproject"):
|
|
473
478
|
return [
|
|
474
|
-
google.cloud.bigquery.Dataset("
|
|
475
|
-
google.cloud.bigquery.Dataset("
|
|
479
|
+
google.cloud.bigquery.Dataset(f"{project}.mydataset"),
|
|
480
|
+
google.cloud.bigquery.Dataset(f"{project}.yourdataset"),
|
|
476
481
|
]
|
|
477
482
|
|
|
478
483
|
def list_tables(self, dataset, page_size):
|
|
@@ -27,6 +27,12 @@ def test_engine_dataset_but_no_project(faux_conn):
|
|
|
27
27
|
assert conn.connection._client.project == "authproj"
|
|
28
28
|
|
|
29
29
|
|
|
30
|
+
def test_engine_dataset_with_billing_project(faux_conn):
|
|
31
|
+
engine = sqlalchemy.create_engine("bigquery://foo", billing_project_id="bar")
|
|
32
|
+
conn = engine.connect()
|
|
33
|
+
assert conn.connection._client.project == "bar"
|
|
34
|
+
|
|
35
|
+
|
|
30
36
|
def test_engine_no_dataset_no_project(faux_conn):
|
|
31
37
|
engine = sqlalchemy.create_engine("bigquery://")
|
|
32
38
|
conn = engine.connect()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/_versions_helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery/requirements.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/requires.txt
RENAMED
|
@@ -8,14 +8,14 @@ sqlalchemy<3.0.0,>=1.4.16
|
|
|
8
8
|
alembic
|
|
9
9
|
|
|
10
10
|
[all]
|
|
11
|
-
grpcio<2.0.0,>=1.47.0
|
|
12
11
|
GeoAlchemy2
|
|
13
|
-
|
|
12
|
+
pyarrow>=3.0.0
|
|
13
|
+
grpcio<2.0.0,>=1.47.0
|
|
14
14
|
shapely
|
|
15
|
-
|
|
15
|
+
alembic
|
|
16
16
|
packaging
|
|
17
17
|
google-cloud-bigquery-storage<3.0.0,>=2.0.0
|
|
18
|
-
|
|
18
|
+
pytz
|
|
19
19
|
|
|
20
20
|
[all:python_version >= "3.11"]
|
|
21
21
|
grpcio<2.0.0,>=1.49.1
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/sqlalchemy_bigquery.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/data/sample_one_row.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/system/test_sqlalchemy_bigquery.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_catalog_functions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sqlalchemy_bigquery-1.13.0 → sqlalchemy_bigquery-1.14.0}/tests/unit/test_sqlalchemy_bigquery.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|