sqlalchemy-bigquery 1.9.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.
Files changed (58) hide show
  1. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/AUTHORS +1 -0
  2. {sqlalchemy-bigquery-1.9.0/sqlalchemy_bigquery.egg-info → sqlalchemy-bigquery-1.11.0}/PKG-INFO +64 -14
  3. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/README.rst +55 -5
  4. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/setup.py +2 -2
  5. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/_struct.py +12 -32
  6. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/base.py +311 -64
  7. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/requirements.py +5 -0
  8. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/version.py +1 -1
  9. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0/sqlalchemy_bigquery.egg-info}/PKG-INFO +64 -14
  10. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/SOURCES.txt +1 -0
  11. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/requires.txt +7 -7
  12. sqlalchemy-bigquery-1.11.0/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +642 -0
  13. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test__struct.py +24 -21
  14. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_alembic.py +7 -10
  15. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_geography.py +14 -6
  16. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_sqlalchemy_bigquery.py +171 -117
  17. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/conftest.py +12 -9
  18. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test__struct.py +2 -2
  19. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_catalog_functions.py +1 -12
  20. sqlalchemy-bigquery-1.11.0/tests/unit/test_compiler.py +390 -0
  21. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_compliance.py +20 -30
  22. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_geography.py +5 -5
  23. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_select.py +46 -126
  24. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_sqlalchemy_bigquery.py +2 -8
  25. sqlalchemy-bigquery-1.11.0/tests/unit/test_table_options.py +474 -0
  26. sqlalchemy-bigquery-1.9.0/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +0 -291
  27. sqlalchemy-bigquery-1.9.0/tests/unit/test_compiler.py +0 -116
  28. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/LICENSE +0 -0
  29. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/MANIFEST.in +0 -0
  30. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/setup.cfg +0 -0
  31. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/__init__.py +0 -0
  32. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/_helpers.py +0 -0
  33. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/_types.py +0 -0
  34. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/geography.py +0 -0
  35. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery/parse_url.py +0 -0
  36. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/dependency_links.txt +0 -0
  37. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/entry_points.txt +0 -0
  38. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/sqlalchemy_bigquery.egg-info/top_level.txt +0 -0
  39. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/__init__.py +0 -0
  40. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/conftest.py +0 -0
  41. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/sqlalchemy_dialect_compliance/README.rst +0 -0
  42. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/sqlalchemy_dialect_compliance/conftest.py +0 -0
  43. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/__init__.py +0 -0
  44. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/conftest.py +0 -0
  45. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/data/sample.json +0 -0
  46. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/data/sample_one_row.json +0 -0
  47. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/data/schema.json +0 -0
  48. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/system/test_helpers.py +0 -0
  49. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/__init__.py +0 -0
  50. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/fauxdbi.py +0 -0
  51. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_comments.py +0 -0
  52. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_dialect_types.py +0 -0
  53. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_engine.py +0 -0
  54. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_helpers.py +0 -0
  55. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_like_reescape.py +0 -0
  56. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_parse_url.py +0 -0
  57. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_version.py +0 -0
  58. {sqlalchemy-bigquery-1.9.0 → sqlalchemy-bigquery-1.11.0}/tests/unit/test_view.py +0 -0
@@ -19,6 +19,7 @@ Maksym Voitko
19
19
  Maxim Zudilov (mxmzdlv)
20
20
  Maxime Beauchemin (mistercrunch)
21
21
  Romain Rigaux
22
+ Sharoon Thomas (sharoonthomas)
22
23
  Sumedh Sakdeo
23
24
  Tim Swast (tswast)
24
25
  Vince Broz
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy-bigquery
3
- Version: 1.9.0
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,>=2.25.2
29
+ Requires-Dist: google-cloud-bigquery<4.0.0dev,>=3.3.6
30
30
  Requires-Dist: packaging
31
- Requires-Dist: sqlalchemy<2.0.0dev,>=1.2.0
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: pytz; extra == "all"
47
+ Requires-Dist: packaging; extra == "all"
48
+ Requires-Dist: pyarrow>=3.0.0; extra == "all"
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"
46
51
  Requires-Dist: alembic; extra == "all"
47
52
  Requires-Dist: GeoAlchemy2; extra == "all"
48
- Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
49
- Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "all"
50
- Requires-Dist: shapely; extra == "all"
51
- Requires-Dist: packaging; extra == "all"
52
- Requires-Dist: pytz; extra == "all"
53
53
  Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "all"
54
- Requires-Dist: pyarrow>=3.0.0; 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
- connect_args={'client': custom_bq_client},
338
+ connect_args={'client': custom_bq_client},
340
339
  )
341
340
 
342
341
 
@@ -347,7 +346,12 @@ To add metadata to a table:
347
346
 
348
347
  .. code-block:: python
349
348
 
350
- table = Table('mytable', ..., bigquery_description='my table description', bigquery_friendly_name='my table friendly name')
349
+ table = Table('mytable', ...,
350
+ bigquery_description='my table description',
351
+ bigquery_friendly_name='my table friendly name',
352
+ bigquery_default_rounding_mode="ROUND_HALF_EVEN",
353
+ bigquery_expiration_timestamp=datetime.datetime.fromisoformat("2038-01-01T00:00:00+00:00"),
354
+ )
351
355
 
352
356
  To add metadata to a column:
353
357
 
@@ -355,6 +359,52 @@ To add metadata to a column:
355
359
 
356
360
  Column('mycolumn', doc='my column description')
357
361
 
362
+ To create a clustered table:
363
+
364
+ .. code-block:: python
365
+
366
+ table = Table('mytable', ..., bigquery_clustering_fields=["a", "b", "c"])
367
+
368
+ To create a time-unit column-partitioned table:
369
+
370
+ .. code-block:: python
371
+
372
+ from google.cloud import bigquery
373
+
374
+ table = Table('mytable', ...,
375
+ bigquery_time_partitioning=bigquery.TimePartitioning(
376
+ field="mytimestamp",
377
+ type_="MONTH",
378
+ expiration_ms=1000 * 60 * 60 * 24 * 30 * 6, # 6 months
379
+ ),
380
+ bigquery_require_partition_filter=True,
381
+ )
382
+
383
+ To create an ingestion-time partitioned table:
384
+
385
+ .. code-block:: python
386
+
387
+ from google.cloud import bigquery
388
+
389
+ table = Table('mytable', ...,
390
+ bigquery_time_partitioning=bigquery.TimePartitioning(),
391
+ bigquery_require_partition_filter=True,
392
+ )
393
+
394
+ To create an integer-range partitioned table
395
+
396
+ .. code-block:: python
397
+
398
+ from google.cloud import bigquery
399
+
400
+ table = Table('mytable', ...,
401
+ bigquery_range_partitioning=bigquery.RangePartitioning(
402
+ field="zipcode",
403
+ range_=bigquery.PartitionRange(start=0, end=100000, interval=10),
404
+ ),
405
+ bigquery_require_partition_filter=True,
406
+ )
407
+
358
408
 
359
409
  Threading and Multiprocessing
360
410
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -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
- connect_args={'client': custom_bq_client},
283
+ connect_args={'client': custom_bq_client},
285
284
  )
286
285
 
287
286
 
@@ -292,7 +291,12 @@ To add metadata to a table:
292
291
 
293
292
  .. code-block:: python
294
293
 
295
- table = Table('mytable', ..., bigquery_description='my table description', bigquery_friendly_name='my table friendly name')
294
+ table = Table('mytable', ...,
295
+ bigquery_description='my table description',
296
+ bigquery_friendly_name='my table friendly name',
297
+ bigquery_default_rounding_mode="ROUND_HALF_EVEN",
298
+ bigquery_expiration_timestamp=datetime.datetime.fromisoformat("2038-01-01T00:00:00+00:00"),
299
+ )
296
300
 
297
301
  To add metadata to a column:
298
302
 
@@ -300,6 +304,52 @@ To add metadata to a column:
300
304
 
301
305
  Column('mycolumn', doc='my column description')
302
306
 
307
+ To create a clustered table:
308
+
309
+ .. code-block:: python
310
+
311
+ table = Table('mytable', ..., bigquery_clustering_fields=["a", "b", "c"])
312
+
313
+ To create a time-unit column-partitioned table:
314
+
315
+ .. code-block:: python
316
+
317
+ from google.cloud import bigquery
318
+
319
+ table = Table('mytable', ...,
320
+ bigquery_time_partitioning=bigquery.TimePartitioning(
321
+ field="mytimestamp",
322
+ type_="MONTH",
323
+ expiration_ms=1000 * 60 * 60 * 24 * 30 * 6, # 6 months
324
+ ),
325
+ bigquery_require_partition_filter=True,
326
+ )
327
+
328
+ To create an ingestion-time partitioned table:
329
+
330
+ .. code-block:: python
331
+
332
+ from google.cloud import bigquery
333
+
334
+ table = Table('mytable', ...,
335
+ bigquery_time_partitioning=bigquery.TimePartitioning(),
336
+ bigquery_require_partition_filter=True,
337
+ )
338
+
339
+ To create an integer-range partitioned table
340
+
341
+ .. code-block:: python
342
+
343
+ from google.cloud import bigquery
344
+
345
+ table = Table('mytable', ...,
346
+ bigquery_range_partitioning=bigquery.RangePartitioning(
347
+ field="zipcode",
348
+ range_=bigquery.PartitionRange(start=0, end=100000, interval=10),
349
+ ),
350
+ bigquery_require_partition_filter=True,
351
+ )
352
+
303
353
 
304
354
  Threading and Multiprocessing
305
355
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -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>=2.25.2,<4.0.0dev",
102
+ "google-cloud-bigquery>=3.3.6,<4.0.0dev",
103
103
  "packaging",
104
- "sqlalchemy>=1.2.0,<2.0.0dev",
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
- sqlalchemy_1_4_or_more = packaging.version.parse(
28
- sqlalchemy.__version__
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
- # In the implementations of _field_index below, we're stealing from
111
- # the JSON type implementation, but the code to steal changed in
112
- # 1.4. :/
113
-
114
- if sqlalchemy_1_4_or_more:
115
-
116
- def _field_index(self, name, operator):
117
- return sqlalchemy.sql.coercions.expect(
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):