sqlalchemy-bigquery 1.4.3__tar.gz → 1.12.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 (68) hide show
  1. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/AUTHORS +1 -0
  2. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/MANIFEST.in +3 -2
  3. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/PKG-INFO +136 -14
  4. sqlalchemy-bigquery-1.4.3/sqlalchemy_bigquery.egg-info/PKG-INFO → sqlalchemy_bigquery-1.12.0/README.rst +106 -39
  5. sqlalchemy_bigquery-1.12.0/pyproject.toml +5 -0
  6. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/setup.py +42 -19
  7. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/__init__.py +5 -3
  8. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/_helpers.py +42 -10
  9. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/_struct.py +14 -34
  10. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/_types.py +2 -2
  11. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/base.py +386 -90
  12. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/geography.py +71 -18
  13. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/parse_url.py +8 -0
  14. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/requirements.py +5 -0
  15. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery/version.py +1 -1
  16. sqlalchemy-bigquery-1.4.3/README.rst → sqlalchemy_bigquery-1.12.0/sqlalchemy_bigquery.egg-info/PKG-INFO +161 -5
  17. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery.egg-info/SOURCES.txt +11 -1
  18. sqlalchemy_bigquery-1.12.0/sqlalchemy_bigquery.egg-info/requires.txt +37 -0
  19. sqlalchemy_bigquery-1.12.0/sqlalchemy_bigquery.egg-info/top_level.txt +2 -0
  20. sqlalchemy_bigquery-1.12.0/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +642 -0
  21. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/conftest.py +6 -2
  22. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/test__struct.py +27 -20
  23. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/test_alembic.py +18 -14
  24. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/test_geography.py +18 -8
  25. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/test_helpers.py +14 -3
  26. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/test_sqlalchemy_bigquery.py +252 -116
  27. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/conftest.py +12 -9
  28. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/fauxdbi.py +4 -3
  29. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test__struct.py +5 -3
  30. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_catalog_functions.py +1 -6
  31. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_comments.py +3 -1
  32. sqlalchemy_bigquery-1.12.0/tests/unit/test_compiler.py +419 -0
  33. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_compliance.py +20 -30
  34. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_geography.py +14 -11
  35. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_helpers.py +29 -14
  36. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_like_reescape.py +0 -2
  37. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_parse_url.py +13 -2
  38. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_select.py +239 -121
  39. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_sqlalchemy_bigquery.py +15 -8
  40. sqlalchemy_bigquery-1.12.0/tests/unit/test_table_options.py +492 -0
  41. sqlalchemy_bigquery-1.12.0/tests/unit/test_version.py +29 -0
  42. sqlalchemy_bigquery-1.12.0/third_party/sqlalchemy_bigquery_vendored/__init__.py +0 -0
  43. sqlalchemy_bigquery-1.12.0/third_party/sqlalchemy_bigquery_vendored/py.typed +0 -0
  44. sqlalchemy_bigquery-1.12.0/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/AUTHORS +30 -0
  45. sqlalchemy_bigquery-1.12.0/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/LICENSE +19 -0
  46. sqlalchemy_bigquery-1.12.0/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/__init__.py +6 -0
  47. sqlalchemy_bigquery-1.12.0/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/postgresql/__init__.py +0 -0
  48. sqlalchemy_bigquery-1.12.0/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/postgresql/base.py +19 -0
  49. sqlalchemy-bigquery-1.4.3/sqlalchemy_bigquery.egg-info/requires.txt +0 -25
  50. sqlalchemy-bigquery-1.4.3/sqlalchemy_bigquery.egg-info/top_level.txt +0 -1
  51. sqlalchemy-bigquery-1.4.3/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +0 -260
  52. sqlalchemy-bigquery-1.4.3/tests/unit/test_compiler.py +0 -114
  53. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/LICENSE +0 -0
  54. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/setup.cfg +0 -0
  55. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery.egg-info/dependency_links.txt +0 -0
  56. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/sqlalchemy_bigquery.egg-info/entry_points.txt +0 -0
  57. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/__init__.py +0 -0
  58. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/conftest.py +0 -0
  59. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/sqlalchemy_dialect_compliance/README.rst +0 -0
  60. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/sqlalchemy_dialect_compliance/conftest.py +0 -0
  61. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/__init__.py +0 -0
  62. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/data/sample.json +0 -0
  63. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/data/sample_one_row.json +0 -0
  64. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/system/data/schema.json +0 -0
  65. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/__init__.py +0 -0
  66. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_dialect_types.py +0 -0
  67. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.0}/tests/unit/test_engine.py +0 -0
  68. {sqlalchemy-bigquery-1.4.3 → sqlalchemy_bigquery-1.12.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
  # -*- coding: utf-8 -*-
2
2
  #
3
- # Copyright 2020 Google LLC
3
+ # Copyright 2024 Google LLC
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -16,7 +16,8 @@
16
16
 
17
17
  # Generated by synthtool. DO NOT EDIT!
18
18
  include README.rst LICENSE
19
- recursive-include google *.json *.proto py.typed
19
+ recursive-include third_party/sqlalchemy_bigquery_vendored *
20
+ recursive-include sqlalchemy_bigquery *.json *.proto py.typed
20
21
  recursive-include tests *
21
22
  global-exclude *.py[co]
22
23
  global-exclude __pycache__
@@ -1,11 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy-bigquery
3
- Version: 1.4.3
3
+ Version: 1.12.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
7
7
  Author-email: googleapis-packages@google.com
8
- License: UNKNOWN
9
8
  Keywords: bigquery,sqlalchemy
10
9
  Platform: Posix; MacOS X; Windows
11
10
  Classifier: Development Status :: 5 - Production/Stable
@@ -13,22 +12,46 @@ Classifier: Intended Audience :: Developers
13
12
  Classifier: License :: OSI Approved :: MIT License
14
13
  Classifier: Programming Language :: Python
15
14
  Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.6
17
- Classifier: Programming Language :: Python :: 3.7
18
15
  Classifier: Programming Language :: Python :: 3.8
19
16
  Classifier: Programming Language :: Python :: 3.9
20
17
  Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
21
20
  Classifier: Operating System :: OS Independent
22
21
  Classifier: Topic :: Database :: Front-Ends
23
22
  Obsoletes: pybigquery
24
- Requires-Python: >=3.6, <3.11
23
+ Requires-Python: >=3.8, <3.13
25
24
  Description-Content-Type: text/x-rst
25
+ License-File: LICENSE
26
+ License-File: AUTHORS
27
+ Requires-Dist: google-api-core!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0,<3.0.0dev,>=1.31.5
28
+ Requires-Dist: google-auth<3.0.0dev,>=1.25.0
29
+ Requires-Dist: google-cloud-bigquery<4.0.0dev,>=3.3.6
30
+ Requires-Dist: packaging
31
+ Requires-Dist: sqlalchemy<3.0.0dev,>=1.4.16
26
32
  Provides-Extra: geography
33
+ Requires-Dist: GeoAlchemy2; extra == "geography"
34
+ Requires-Dist: shapely; extra == "geography"
27
35
  Provides-Extra: alembic
36
+ Requires-Dist: alembic; extra == "alembic"
28
37
  Provides-Extra: tests
38
+ Requires-Dist: packaging; extra == "tests"
39
+ Requires-Dist: pytz; extra == "tests"
40
+ Provides-Extra: bqstorage
41
+ Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "bqstorage"
42
+ Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "bqstorage"
43
+ Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "bqstorage"
44
+ Requires-Dist: pyarrow>=3.0.0; extra == "bqstorage"
29
45
  Provides-Extra: all
30
- License-File: LICENSE
31
- License-File: AUTHORS
46
+ Requires-Dist: pytz; extra == "all"
47
+ Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
48
+ Requires-Dist: alembic; extra == "all"
49
+ Requires-Dist: grpcio<2.0dev,>=1.49.1; python_version >= "3.11" and extra == "all"
50
+ Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "all"
51
+ Requires-Dist: packaging; extra == "all"
52
+ Requires-Dist: pyarrow>=3.0.0; extra == "all"
53
+ Requires-Dist: GeoAlchemy2; extra == "all"
54
+ Requires-Dist: shapely; extra == "all"
32
55
 
33
56
  SQLAlchemy Dialect for BigQuery
34
57
  ===============================
@@ -66,6 +89,7 @@ In order to use this library, you first need to go through the following steps:
66
89
  .. _Enable the BigQuery Storage API.: https://console.cloud.google.com/apis/library/bigquery.googleapis.com
67
90
  .. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
68
91
 
92
+
69
93
  Installation
70
94
  ------------
71
95
 
@@ -82,11 +106,11 @@ dependencies.
82
106
 
83
107
  Supported Python Versions
84
108
  ^^^^^^^^^^^^^^^^^^^^^^^^^
85
- Python >= 3.6
109
+ Python >= 3.8
86
110
 
87
111
  Unsupported Python Versions
88
112
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
89
- Python <= 3.5.
113
+ Python <= 3.7.
90
114
 
91
115
 
92
116
  Mac/Linux
@@ -110,6 +134,20 @@ Windows
110
134
  <your-env>\Scripts\activate
111
135
  <your-env>\Scripts\pip.exe install sqlalchemy-bigquery
112
136
 
137
+
138
+ Installations when processing large datasets
139
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
140
+
141
+ When handling large datasets, you may see speed increases by also installing the
142
+ `bqstorage` dependencies. See the instructions above about creating a virtual
143
+ environment and then install `sqlalchemy-bigquery` using the `bqstorage` extras:
144
+
145
+ .. code-block:: console
146
+
147
+ source <your-env>/bin/activate
148
+ <your-env>/bin/pip install sqlalchemy-bigquery[bqstorage]
149
+
150
+
113
151
  Usage
114
152
  -----
115
153
 
@@ -123,7 +161,8 @@ SQLAlchemy
123
161
  from sqlalchemy.schema import *
124
162
  engine = create_engine('bigquery://project')
125
163
  table = Table('dataset.table', MetaData(bind=engine), autoload=True)
126
- print(select([func.count('*')], from_obj=table).scalar())
164
+ print(select([func.count('*')], from_obj=table().scalar()))
165
+
127
166
 
128
167
  Project
129
168
  ^^^^^^^
@@ -133,12 +172,27 @@ Project
133
172
  Authentication
134
173
  ^^^^^^^^^^^^^^
135
174
 
136
- Follow the `Google Cloud library guide <https://google-cloud-python.readthedocs.io/en/latest/core/auth.html>`_ for authentication. Alternatively, you can provide the path to a service account JSON file in ``create_engine()``:
175
+ Follow the `Google Cloud library guide <https://google-cloud-python.readthedocs.io/en/latest/core/auth.html>`_ for authentication.
176
+
177
+ Alternatively, you can choose either of the following approaches:
178
+
179
+ * provide the path to a service account JSON file in ``create_engine()`` using the ``credentials_path`` parameter:
137
180
 
138
181
  .. code-block:: python
139
182
 
183
+ # provide the path to a service account JSON file
140
184
  engine = create_engine('bigquery://', credentials_path='/path/to/keyfile.json')
141
185
 
186
+ * pass the credentials in ``create_engine()`` as a Python dictionary using the ``credentials_info`` parameter:
187
+
188
+ .. code-block:: python
189
+
190
+ # provide credentials as a Python dictionary
191
+ credentials_info = {
192
+ "type": "service_account",
193
+ "project_id": "your-service-account-project-id"
194
+ },
195
+ engine = create_engine('bigquery://', credentials_info=credentials_info)
142
196
 
143
197
  Location
144
198
  ^^^^^^^^
@@ -266,6 +320,25 @@ To create the base64 encoded string you can use the command line tool ``base64``
266
320
 
267
321
  Alternatively, you can use an online generator like `www.base64encode.org <https://www.base64encode.org>_` to paste your credentials JSON file to be encoded.
268
322
 
323
+
324
+ Supplying Your Own BigQuery Client
325
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
326
+
327
+ The above connection string parameters allow you to influence how the BigQuery client used to execute your queries will be instantiated.
328
+ If you need additional control, you can supply a BigQuery client of your own:
329
+
330
+ .. code-block:: python
331
+
332
+ from google.cloud import bigquery
333
+
334
+ custom_bq_client = bigquery.Client(...)
335
+
336
+ engine = create_engine(
337
+ 'bigquery://some-project/some-dataset?user_supplied_client=True',
338
+ connect_args={'client': custom_bq_client},
339
+ )
340
+
341
+
269
342
  Creating tables
270
343
  ^^^^^^^^^^^^^^^
271
344
 
@@ -273,7 +346,12 @@ To add metadata to a table:
273
346
 
274
347
  .. code-block:: python
275
348
 
276
- 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
+ )
277
355
 
278
356
  To add metadata to a column:
279
357
 
@@ -281,6 +359,52 @@ To add metadata to a column:
281
359
 
282
360
  Column('mycolumn', doc='my column description')
283
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
+
284
408
 
285
409
  Threading and Multiprocessing
286
410
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -292,5 +416,3 @@ In multiprocessing scenarios, the best
292
416
  practice is to create client instances *after* the invocation of
293
417
  `os.fork` by `multiprocessing.pool.Pool` or
294
418
  `multiprocessing.Process`.
295
-
296
-
@@ -1,35 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: sqlalchemy-bigquery
3
- Version: 1.4.3
4
- Summary: SQLAlchemy dialect for BigQuery
5
- Home-page: https://github.com/googleapis/python-bigquery-sqlalchemy
6
- Author: The Sqlalchemy-Bigquery Authors
7
- Author-email: googleapis-packages@google.com
8
- License: UNKNOWN
9
- Keywords: bigquery,sqlalchemy
10
- Platform: Posix; MacOS X; Windows
11
- Classifier: Development Status :: 5 - Production/Stable
12
- Classifier: Intended Audience :: Developers
13
- Classifier: License :: OSI Approved :: MIT License
14
- Classifier: Programming Language :: Python
15
- Classifier: Programming Language :: Python :: 3
16
- Classifier: Programming Language :: Python :: 3.6
17
- Classifier: Programming Language :: Python :: 3.7
18
- Classifier: Programming Language :: Python :: 3.8
19
- Classifier: Programming Language :: Python :: 3.9
20
- Classifier: Programming Language :: Python :: 3.10
21
- Classifier: Operating System :: OS Independent
22
- Classifier: Topic :: Database :: Front-Ends
23
- Obsoletes: pybigquery
24
- Requires-Python: >=3.6, <3.11
25
- Description-Content-Type: text/x-rst
26
- Provides-Extra: geography
27
- Provides-Extra: alembic
28
- Provides-Extra: tests
29
- Provides-Extra: all
30
- License-File: LICENSE
31
- License-File: AUTHORS
32
-
33
1
  SQLAlchemy Dialect for BigQuery
34
2
  ===============================
35
3
 
@@ -66,6 +34,7 @@ In order to use this library, you first need to go through the following steps:
66
34
  .. _Enable the BigQuery Storage API.: https://console.cloud.google.com/apis/library/bigquery.googleapis.com
67
35
  .. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
68
36
 
37
+
69
38
  Installation
70
39
  ------------
71
40
 
@@ -82,11 +51,11 @@ dependencies.
82
51
 
83
52
  Supported Python Versions
84
53
  ^^^^^^^^^^^^^^^^^^^^^^^^^
85
- Python >= 3.6
54
+ Python >= 3.8
86
55
 
87
56
  Unsupported Python Versions
88
57
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^
89
- Python <= 3.5.
58
+ Python <= 3.7.
90
59
 
91
60
 
92
61
  Mac/Linux
@@ -110,6 +79,20 @@ Windows
110
79
  <your-env>\Scripts\activate
111
80
  <your-env>\Scripts\pip.exe install sqlalchemy-bigquery
112
81
 
82
+
83
+ Installations when processing large datasets
84
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
85
+
86
+ When handling large datasets, you may see speed increases by also installing the
87
+ `bqstorage` dependencies. See the instructions above about creating a virtual
88
+ environment and then install `sqlalchemy-bigquery` using the `bqstorage` extras:
89
+
90
+ .. code-block:: console
91
+
92
+ source <your-env>/bin/activate
93
+ <your-env>/bin/pip install sqlalchemy-bigquery[bqstorage]
94
+
95
+
113
96
  Usage
114
97
  -----
115
98
 
@@ -123,7 +106,8 @@ SQLAlchemy
123
106
  from sqlalchemy.schema import *
124
107
  engine = create_engine('bigquery://project')
125
108
  table = Table('dataset.table', MetaData(bind=engine), autoload=True)
126
- print(select([func.count('*')], from_obj=table).scalar())
109
+ print(select([func.count('*')], from_obj=table().scalar()))
110
+
127
111
 
128
112
  Project
129
113
  ^^^^^^^
@@ -133,12 +117,27 @@ Project
133
117
  Authentication
134
118
  ^^^^^^^^^^^^^^
135
119
 
136
- Follow the `Google Cloud library guide <https://google-cloud-python.readthedocs.io/en/latest/core/auth.html>`_ for authentication. Alternatively, you can provide the path to a service account JSON file in ``create_engine()``:
120
+ Follow the `Google Cloud library guide <https://google-cloud-python.readthedocs.io/en/latest/core/auth.html>`_ for authentication.
121
+
122
+ Alternatively, you can choose either of the following approaches:
123
+
124
+ * provide the path to a service account JSON file in ``create_engine()`` using the ``credentials_path`` parameter:
137
125
 
138
126
  .. code-block:: python
139
127
 
128
+ # provide the path to a service account JSON file
140
129
  engine = create_engine('bigquery://', credentials_path='/path/to/keyfile.json')
141
130
 
131
+ * pass the credentials in ``create_engine()`` as a Python dictionary using the ``credentials_info`` parameter:
132
+
133
+ .. code-block:: python
134
+
135
+ # provide credentials as a Python dictionary
136
+ credentials_info = {
137
+ "type": "service_account",
138
+ "project_id": "your-service-account-project-id"
139
+ },
140
+ engine = create_engine('bigquery://', credentials_info=credentials_info)
142
141
 
143
142
  Location
144
143
  ^^^^^^^^
@@ -266,6 +265,25 @@ To create the base64 encoded string you can use the command line tool ``base64``
266
265
 
267
266
  Alternatively, you can use an online generator like `www.base64encode.org <https://www.base64encode.org>_` to paste your credentials JSON file to be encoded.
268
267
 
268
+
269
+ Supplying Your Own BigQuery Client
270
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
271
+
272
+ The above connection string parameters allow you to influence how the BigQuery client used to execute your queries will be instantiated.
273
+ If you need additional control, you can supply a BigQuery client of your own:
274
+
275
+ .. code-block:: python
276
+
277
+ from google.cloud import bigquery
278
+
279
+ custom_bq_client = bigquery.Client(...)
280
+
281
+ engine = create_engine(
282
+ 'bigquery://some-project/some-dataset?user_supplied_client=True',
283
+ connect_args={'client': custom_bq_client},
284
+ )
285
+
286
+
269
287
  Creating tables
270
288
  ^^^^^^^^^^^^^^^
271
289
 
@@ -273,7 +291,12 @@ To add metadata to a table:
273
291
 
274
292
  .. code-block:: python
275
293
 
276
- 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
+ )
277
300
 
278
301
  To add metadata to a column:
279
302
 
@@ -281,6 +304,52 @@ To add metadata to a column:
281
304
 
282
305
  Column('mycolumn', doc='my column description')
283
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
+
284
353
 
285
354
  Threading and Multiprocessing
286
355
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -292,5 +361,3 @@ In multiprocessing scenarios, the best
292
361
  practice is to create client instances *after* the invocation of
293
362
  `os.fork` by `multiprocessing.pool.Pool` or
294
363
  `multiprocessing.Process`.
295
-
296
-
@@ -0,0 +1,5 @@
1
+ # Added so third_party folder is included when running `pip install -e .`
2
+ # See PR #1083 for more detail
3
+ [build-system]
4
+ requires = ["setuptools"]
5
+ build-backend = "setuptools.build_meta"
@@ -22,6 +22,7 @@ import io
22
22
  import itertools
23
23
  import os
24
24
  import re
25
+ import setuptools
25
26
  from setuptools import setup
26
27
 
27
28
  # Package metadata.
@@ -45,13 +46,38 @@ def readme():
45
46
  return f.read()
46
47
 
47
48
 
48
- extras = dict(
49
- geography=["GeoAlchemy2", "shapely"],
50
- alembic=["alembic"],
51
- tests=["packaging", "pytz"],
52
- )
49
+ extras = {
50
+ "geography": ["GeoAlchemy2", "shapely"],
51
+ "alembic": ["alembic"],
52
+ "tests": ["packaging", "pytz"],
53
+ # Keep the no-op bqstorage extra for backward compatibility.
54
+ # See: https://github.com/googleapis/python-bigquery/issues/757
55
+ "bqstorage": [
56
+ "google-cloud-bigquery-storage >= 2.0.0, <3.0.0dev",
57
+ # Due to an issue in pip's dependency resolver, the `grpc` extra is not
58
+ # installed, even though `google-cloud-bigquery-storage` specifies it
59
+ # as `google-api-core[grpc]`. We thus need to explicitly specify it here.
60
+ # See: https://github.com/googleapis/python-bigquery/issues/83 The
61
+ # grpc.Channel.close() method isn't added until 1.32.0.
62
+ # https://github.com/grpc/grpc/pull/15254
63
+ "grpcio >= 1.47.0, < 2.0dev",
64
+ "grpcio >= 1.49.1, < 2.0dev; python_version>='3.11'",
65
+ "pyarrow >= 3.0.0",
66
+ ],
67
+ }
68
+
53
69
  extras["all"] = set(itertools.chain.from_iterable(extras.values()))
54
70
 
71
+ packages = [
72
+ package
73
+ for package in setuptools.find_namespace_packages()
74
+ if package.startswith("sqlalchemy_bigquery")
75
+ ] + [
76
+ package
77
+ for package in setuptools.find_namespace_packages("third_party")
78
+ if package.startswith("sqlalchemy_bigquery_vendored")
79
+ ]
80
+
55
81
  setup(
56
82
  name=name,
57
83
  version=version,
@@ -60,7 +86,11 @@ setup(
60
86
  long_description_content_type="text/x-rst",
61
87
  author="The Sqlalchemy-Bigquery Authors",
62
88
  author_email="googleapis-packages@google.com",
63
- packages=["sqlalchemy_bigquery"],
89
+ package_dir={
90
+ "sqlalchemy-bigquery": "sqlalchemy_bigquery",
91
+ "sqlalchemy_bigquery_vendored": "third_party/sqlalchemy_bigquery_vendored",
92
+ },
93
+ packages=packages,
64
94
  url="https://github.com/googleapis/python-bigquery-sqlalchemy",
65
95
  keywords=["bigquery", "sqlalchemy"],
66
96
  classifiers=[
@@ -69,11 +99,11 @@ setup(
69
99
  "License :: OSI Approved :: MIT License",
70
100
  "Programming Language :: Python",
71
101
  "Programming Language :: Python :: 3",
72
- "Programming Language :: Python :: 3.6",
73
- "Programming Language :: Python :: 3.7",
74
102
  "Programming Language :: Python :: 3.8",
75
103
  "Programming Language :: Python :: 3.9",
76
104
  "Programming Language :: Python :: 3.10",
105
+ "Programming Language :: Python :: 3.11",
106
+ "Programming Language :: Python :: 3.12",
77
107
  "Operating System :: OS Independent",
78
108
  "Topic :: Database :: Front-Ends",
79
109
  ],
@@ -84,19 +114,12 @@ setup(
84
114
  # Until this issue is closed
85
115
  # https://github.com/googleapis/google-cloud-python/issues/10566
86
116
  "google-auth>=1.25.0,<3.0.0dev", # Work around pip wack.
87
- "google-cloud-bigquery>=2.25.2,<4.0.0dev",
88
- "google-cloud-bigquery-storage>=2.0.0,<3.0.0dev",
89
- "pyarrow>=3.0.0,<7.0dev",
90
- # Temporarily set maximimum sqlalchemy to a known-working version while
91
- # we debug failing compliance tests. See:
92
- # https://github.com/googleapis/python-bigquery-sqlalchemy/issues/386
93
- # and
94
- # https://github.com/googleapis/python-bigquery-sqlalchemy/issues/385
95
- "sqlalchemy>=1.2.0,<=1.4.27",
96
- "future",
117
+ "google-cloud-bigquery>=3.3.6,<4.0.0dev",
118
+ "packaging",
119
+ "sqlalchemy>=1.4.16,<3.0.0dev",
97
120
  ],
98
121
  extras_require=extras,
99
- python_requires=">=3.6, <3.11",
122
+ python_requires=">=3.8, <3.13",
100
123
  tests_require=["packaging", "pytz"],
101
124
  entry_points={
102
125
  "sqlalchemy.dialects": ["bigquery = sqlalchemy_bigquery:BigQueryDialect"]
@@ -20,9 +20,9 @@
20
20
  SQLAlchemy dialect for Google BigQuery
21
21
  """
22
22
 
23
- from .version import __version__ # noqa
23
+ from .version import __version__
24
24
 
25
- from .base import BigQueryDialect, dialect # noqa
25
+ from .base import BigQueryDialect, dialect
26
26
  from ._types import (
27
27
  ARRAY,
28
28
  BIGNUMERIC,
@@ -44,6 +44,8 @@ from ._types import (
44
44
  )
45
45
 
46
46
  __all__ = [
47
+ "__version__",
48
+ "dialect",
47
49
  "ARRAY",
48
50
  "BIGNUMERIC",
49
51
  "BigQueryDialect",
@@ -66,7 +68,7 @@ __all__ = [
66
68
 
67
69
  try:
68
70
  from .geography import GEOGRAPHY, WKB, WKT # noqa
69
- except ImportError:
71
+ except ImportError: # pragma: NO COVER
70
72
  pass
71
73
  else:
72
74
  __all__.extend(["GEOGRAPHY", "WKB", "WKT"])