sqlalchemy-bigquery 1.12.0__tar.gz → 1.12.1__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 (66) hide show
  1. {sqlalchemy_bigquery-1.12.0/sqlalchemy_bigquery.egg-info → sqlalchemy_bigquery-1.12.1}/PKG-INFO +7 -7
  2. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/README.rst +1 -1
  3. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/setup.cfg +1 -1
  4. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/__init__.py +16 -0
  5. sqlalchemy_bigquery-1.12.1/sqlalchemy_bigquery/_versions_helpers.py +32 -0
  6. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/base.py +99 -26
  7. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/version.py +1 -1
  8. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1/sqlalchemy_bigquery.egg-info}/PKG-INFO +7 -7
  9. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery.egg-info/SOURCES.txt +2 -0
  10. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/test_alembic.py +9 -2
  11. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/test_sqlalchemy_bigquery.py +10 -1
  12. sqlalchemy_bigquery-1.12.1/tests/unit/test_alembic.py +37 -0
  13. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_compiler.py +39 -0
  14. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_table_options.py +123 -70
  15. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/AUTHORS +0 -0
  16. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/LICENSE +0 -0
  17. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/MANIFEST.in +0 -0
  18. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/pyproject.toml +0 -0
  19. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/setup.py +0 -0
  20. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/_helpers.py +0 -0
  21. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/_struct.py +0 -0
  22. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/_types.py +0 -0
  23. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/geography.py +0 -0
  24. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/parse_url.py +0 -0
  25. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery/requirements.py +0 -0
  26. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery.egg-info/dependency_links.txt +0 -0
  27. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery.egg-info/entry_points.txt +0 -0
  28. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery.egg-info/requires.txt +5 -5
  29. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/sqlalchemy_bigquery.egg-info/top_level.txt +0 -0
  30. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/__init__.py +0 -0
  31. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/conftest.py +0 -0
  32. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/sqlalchemy_dialect_compliance/README.rst +0 -0
  33. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/sqlalchemy_dialect_compliance/conftest.py +0 -0
  34. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/sqlalchemy_dialect_compliance/test_dialect_compliance.py +0 -0
  35. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/__init__.py +0 -0
  36. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/conftest.py +0 -0
  37. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/data/sample.json +0 -0
  38. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/data/sample_one_row.json +0 -0
  39. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/data/schema.json +0 -0
  40. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/test__struct.py +0 -0
  41. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/test_geography.py +0 -0
  42. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/system/test_helpers.py +0 -0
  43. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/__init__.py +0 -0
  44. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/conftest.py +0 -0
  45. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/fauxdbi.py +0 -0
  46. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test__struct.py +0 -0
  47. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_catalog_functions.py +0 -0
  48. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_comments.py +0 -0
  49. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_compliance.py +0 -0
  50. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_dialect_types.py +0 -0
  51. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_engine.py +0 -0
  52. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_geography.py +0 -0
  53. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_helpers.py +0 -0
  54. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_like_reescape.py +0 -0
  55. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_parse_url.py +0 -0
  56. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_select.py +0 -0
  57. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_sqlalchemy_bigquery.py +0 -0
  58. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_version.py +0 -0
  59. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/tests/unit/test_view.py +0 -0
  60. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/third_party/sqlalchemy_bigquery_vendored/__init__.py +0 -0
  61. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/third_party/sqlalchemy_bigquery_vendored/py.typed +0 -0
  62. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/AUTHORS +0 -0
  63. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/LICENSE +0 -0
  64. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/__init__.py +0 -0
  65. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/postgresql/__init__.py +0 -0
  66. {sqlalchemy_bigquery-1.12.0 → sqlalchemy_bigquery-1.12.1}/third_party/sqlalchemy_bigquery_vendored/sqlalchemy/postgresql/base.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy-bigquery
3
- Version: 1.12.0
3
+ Version: 1.12.1
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.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: GeoAlchemy2; extra == "all"
47
+ Requires-Dist: shapely; extra == "all"
48
+ Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "all"
46
49
  Requires-Dist: pytz; extra == "all"
50
+ Requires-Dist: packaging; extra == "all"
51
+ Requires-Dist: pyarrow>=3.0.0; extra == "all"
47
52
  Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
48
53
  Requires-Dist: alembic; extra == "all"
49
54
  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"
55
55
 
56
56
  SQLAlchemy Dialect for BigQuery
57
57
  ===============================
@@ -191,7 +191,7 @@ Alternatively, you can choose either of the following approaches:
191
191
  credentials_info = {
192
192
  "type": "service_account",
193
193
  "project_id": "your-service-account-project-id"
194
- },
194
+ }
195
195
  engine = create_engine('bigquery://', credentials_info=credentials_info)
196
196
 
197
197
  Location
@@ -136,7 +136,7 @@ Alternatively, you can choose either of the following approaches:
136
136
  credentials_info = {
137
137
  "type": "service_account",
138
138
  "project_id": "your-service-account-project-id"
139
- },
139
+ }
140
140
  engine = create_engine('bigquery://', credentials_info=credentials_info)
141
141
 
142
142
  Location
@@ -6,7 +6,7 @@ requirement_cls = sqlalchemy_bigquery.requirements:Requirements
6
6
  profile_file = .sqlalchemy_dialect_compliance-profiles.txt
7
7
 
8
8
  [tool:pytest]
9
- addopts = --tb native -v -r fxX -p no:warnings
9
+ addopts = --tb native -v -r fxX
10
10
  python_files = tests/*test_*.py
11
11
 
12
12
  [egg_info]
@@ -20,6 +20,8 @@
20
20
  SQLAlchemy dialect for Google BigQuery
21
21
  """
22
22
 
23
+ import warnings
24
+
23
25
  from .version import __version__
24
26
 
25
27
  from .base import BigQueryDialect, dialect
@@ -43,6 +45,20 @@ from ._types import (
43
45
  TIMESTAMP,
44
46
  )
45
47
 
48
+ from . import _versions_helpers
49
+
50
+ sys_major, sys_minor, sys_micro = _versions_helpers.extract_runtime_version()
51
+ if sys_major == 3 and sys_minor in (7, 8):
52
+ warnings.warn(
53
+ "The python-bigquery library will stop supporting Python 3.7 "
54
+ "and Python 3.8 in a future major release expected in Q4 2024. "
55
+ f"Your Python version is {sys_major}.{sys_minor}.{sys_micro}. We "
56
+ "recommend that you update soon to ensure ongoing support. For "
57
+ "more details, see: [Google Cloud Client Libraries Supported Python Versions policy](https://cloud.google.com/python/docs/supported-python-versions)",
58
+ PendingDeprecationWarning,
59
+ )
60
+
61
+
46
62
  __all__ = [
47
63
  "__version__",
48
64
  "dialect",
@@ -0,0 +1,32 @@
1
+ # Copyright 2024 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Shared helper functions for verifying versions of installed modules."""
16
+
17
+
18
+ import sys
19
+ from typing import Tuple
20
+
21
+
22
+ def extract_runtime_version() -> Tuple[int, int, int]:
23
+ # Retrieve the version information
24
+ version_info = sys.version_info
25
+
26
+ # Extract the major, minor, and micro components
27
+ major = version_info.major
28
+ minor = version_info.minor
29
+ micro = version_info.micro
30
+
31
+ # Display the version number in a clear format
32
+ return major, minor, micro
@@ -343,10 +343,8 @@ class BigQueryCompiler(_struct.SQLCompiler, vendored_postgresql.PGCompiler):
343
343
  if within_group_by:
344
344
  column_label = args[0]
345
345
  sql_keywords = {"GROUPING SETS", "ROLLUP", "CUBE"}
346
- for keyword in sql_keywords:
347
- if keyword in str(column_label):
348
- break
349
- else: # for/else always happens unless break gets called
346
+ label_str = column_label.compile(dialect=self.dialect).string
347
+ if not any(keyword in label_str for keyword in sql_keywords):
350
348
  kwargs["render_label_as_label"] = column_label
351
349
 
352
350
  return super(BigQueryCompiler, self).visit_label(*args, **kwargs)
@@ -812,42 +810,99 @@ class BigQueryDDLCompiler(DDLCompiler):
812
810
  )
813
811
 
814
812
  def _process_time_partitioning(
815
- self, table: Table, time_partitioning: TimePartitioning
813
+ self,
814
+ table: Table,
815
+ time_partitioning: TimePartitioning,
816
816
  ):
817
817
  """
818
- Generates a SQL 'PARTITION BY' clause for partitioning a table by a date or timestamp.
818
+ Generates a SQL 'PARTITION BY' clause for partitioning a table,
819
819
 
820
820
  Args:
821
- - table (Table): The SQLAlchemy table object representing the BigQuery table to be partitioned.
821
+ - table (Table): The SQLAlchemy table object representing the BigQuery
822
+ table to be partitioned.
822
823
  - time_partitioning (TimePartitioning): The time partitioning details,
823
824
  including the field to be used for partitioning.
824
825
 
825
826
  Returns:
826
- - str: A SQL 'PARTITION BY' clause that uses either TIMESTAMP_TRUNC or DATE_TRUNC to
827
- partition data on the specified field.
827
+ - str: A SQL 'PARTITION BY' clause.
828
828
 
829
829
  Example:
830
- - Given a table with a TIMESTAMP type column 'event_timestamp' and setting
831
- 'time_partitioning.field' to 'event_timestamp', the function returns
830
+ - Given a table with an 'event_timestamp' and setting time_partitioning.type
831
+ as DAY and by setting 'time_partitioning.field' as 'event_timestamp', the
832
+ function returns:
832
833
  "PARTITION BY TIMESTAMP_TRUNC(event_timestamp, DAY)".
834
+
835
+ Current inputs allowed by BQ and covered by this function include:
836
+ * _PARTITIONDATE
837
+ * DATETIME_TRUNC(<datetime_column>, DAY/HOUR/MONTH/YEAR)
838
+ * TIMESTAMP_TRUNC(<timestamp_column>, DAY/HOUR/MONTH/YEAR)
839
+ * DATE_TRUNC(<date_column>, MONTH/YEAR)
840
+
841
+ Additional options allowed by BQ but not explicitly covered by this
842
+ function include:
843
+ * DATE(_PARTITIONTIME)
844
+ * DATE(<timestamp_column>)
845
+ * DATE(<datetime_column>)
846
+ * DATE column
833
847
  """
834
- field = "_PARTITIONDATE"
835
- trunc_fn = "DATE_TRUNC"
836
848
 
849
+ sqltypes = {
850
+ "_PARTITIONDATE": ("_PARTITIONDATE", None),
851
+ "TIMESTAMP": ("TIMESTAMP_TRUNC", {"DAY", "HOUR", "MONTH", "YEAR"}),
852
+ "DATETIME": ("DATETIME_TRUNC", {"DAY", "HOUR", "MONTH", "YEAR"}),
853
+ "DATE": ("DATE_TRUNC", {"MONTH", "YEAR"}),
854
+ }
855
+
856
+ # Extract field (i.e <column_name> or _PARTITIONDATE)
857
+ # AND extract the name of the column_type (i.e. "TIMESTAMP", "DATE",
858
+ # "DATETIME", "_PARTITIONDATE")
837
859
  if time_partitioning.field is not None:
838
860
  field = time_partitioning.field
839
- if isinstance(
840
- table.columns[time_partitioning.field].type,
841
- sqlalchemy.sql.sqltypes.DATE,
842
- ):
843
- return f"PARTITION BY {field}"
844
- elif isinstance(
845
- table.columns[time_partitioning.field].type,
846
- sqlalchemy.sql.sqltypes.TIMESTAMP,
847
- ):
848
- trunc_fn = "TIMESTAMP_TRUNC"
861
+ column_type = table.columns[field].type.__visit_name__.upper()
849
862
 
850
- return f"PARTITION BY {trunc_fn}({field}, {time_partitioning.type_})"
863
+ else:
864
+ field = "_PARTITIONDATE"
865
+ column_type = "_PARTITIONDATE"
866
+
867
+ # Extract time_partitioning.type_ (DAY, HOUR, MONTH, YEAR)
868
+ # i.e. generates one partition per type (1/DAY, 1/HOUR)
869
+ # NOTE: if time_partitioning.type_ == None, it gets
870
+ # immediately overwritten by python-bigquery to a default of DAY.
871
+ partitioning_period = time_partitioning.type_
872
+
873
+ # Extract the truncation_function (i.e. DATE_TRUNC)
874
+ # and the set of allowable partition_periods
875
+ # that can be used in that function
876
+ trunc_fn, allowed_partitions = sqltypes[column_type]
877
+
878
+ # Create output:
879
+ # Special Case: _PARTITIONDATE does NOT use a function or partitioning_period
880
+ if trunc_fn == "_PARTITIONDATE":
881
+ return f"PARTITION BY {field}"
882
+
883
+ # Special Case: BigQuery will not accept DAY as partitioning_period for
884
+ # DATE_TRUNC.
885
+ # However, the default argument in python-bigquery for TimePartioning
886
+ # is DAY. This case overwrites that to avoid making a breaking change in
887
+ # python-bigquery.
888
+ # https://github.com/googleapis/python-bigquery/blob/a4d9534a900f13ae7355904cda05097d781f27e3/google/cloud/bigquery/table.py#L2916
889
+ if trunc_fn == "DATE_TRUNC" and partitioning_period == "DAY":
890
+ raise ValueError(
891
+ "The TimePartitioning.type_ must be one of: "
892
+ f"{allowed_partitions}, received {partitioning_period}."
893
+ "NOTE: the `default` value for TimePartioning.type_ as set in "
894
+ "python-bigquery is 'DAY', if you wish to use 'DATE_TRUNC' "
895
+ "ensure that you overwrite the default TimePartitioning.type_. "
896
+ )
897
+
898
+ # Generic Case
899
+ if partitioning_period not in allowed_partitions:
900
+ raise ValueError(
901
+ "The TimePartitioning.type_ must be one of: "
902
+ f"{allowed_partitions}, received {partitioning_period}."
903
+ )
904
+
905
+ return f"PARTITION BY {trunc_fn}({field}, {partitioning_period})"
851
906
 
852
907
  def _process_range_partitioning(
853
908
  self, table: Table, range_partitioning: RangePartitioning
@@ -1331,18 +1386,36 @@ except ImportError: # pragma: NO COVER
1331
1386
  pass
1332
1387
  else:
1333
1388
  from alembic.ddl import impl
1334
- from alembic.ddl.base import ColumnType, format_type, alter_table, alter_column
1389
+ from alembic.ddl.base import (
1390
+ ColumnName,
1391
+ ColumnType,
1392
+ format_column_name,
1393
+ format_type,
1394
+ alter_table,
1395
+ alter_column,
1396
+ )
1335
1397
 
1336
1398
  class SqlalchemyBigqueryImpl(impl.DefaultImpl):
1337
1399
  __dialect__ = "bigquery"
1338
1400
 
1401
+ @compiles(ColumnName, "bigquery")
1402
+ def visit_column_name(element: ColumnName, compiler: DDLCompiler, **kw) -> str:
1403
+ """Replaces the visit_column_name() function in alembic/alembic/ddl/base.py.
1404
+ See https://github.com/googleapis/python-bigquery-sqlalchemy/issues/1097"""
1405
+
1406
+ return "%s RENAME COLUMN %s TO %s" % (
1407
+ alter_table(compiler, element.table_name, element.schema),
1408
+ format_column_name(compiler, element.column_name),
1409
+ format_column_name(compiler, element.newname),
1410
+ )
1411
+
1339
1412
  @compiles(ColumnType, "bigquery")
1340
1413
  def visit_column_type(element: ColumnType, compiler: DDLCompiler, **kw) -> str:
1341
1414
  """Replaces the visit_column_type() function in alembic/alembic/ddl/base.py.
1342
1415
  The alembic version ends in TYPE <element type>, but bigquery requires this syntax:
1343
1416
  SET DATA TYPE <element type>"""
1344
1417
 
1345
- return "%s %s %s" % ( # pragma: NO COVER
1418
+ return "%s %s %s" % (
1346
1419
  alter_table(compiler, element.table_name, element.schema),
1347
1420
  alter_column(compiler, element.column_name),
1348
1421
  "SET DATA TYPE %s" % format_type(compiler, element.type_),
@@ -17,4 +17,4 @@
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
- __version__ = "1.12.0"
20
+ __version__ = "1.12.1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sqlalchemy-bigquery
3
- Version: 1.12.0
3
+ Version: 1.12.1
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.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: GeoAlchemy2; extra == "all"
47
+ Requires-Dist: shapely; extra == "all"
48
+ Requires-Dist: grpcio<2.0dev,>=1.47.0; extra == "all"
46
49
  Requires-Dist: pytz; extra == "all"
50
+ Requires-Dist: packaging; extra == "all"
51
+ Requires-Dist: pyarrow>=3.0.0; extra == "all"
47
52
  Requires-Dist: google-cloud-bigquery-storage<3.0.0dev,>=2.0.0; extra == "all"
48
53
  Requires-Dist: alembic; extra == "all"
49
54
  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"
55
55
 
56
56
  SQLAlchemy Dialect for BigQuery
57
57
  ===============================
@@ -191,7 +191,7 @@ Alternatively, you can choose either of the following approaches:
191
191
  credentials_info = {
192
192
  "type": "service_account",
193
193
  "project_id": "your-service-account-project-id"
194
- },
194
+ }
195
195
  engine = create_engine('bigquery://', credentials_info=credentials_info)
196
196
 
197
197
  Location
@@ -9,6 +9,7 @@ sqlalchemy_bigquery/__init__.py
9
9
  sqlalchemy_bigquery/_helpers.py
10
10
  sqlalchemy_bigquery/_struct.py
11
11
  sqlalchemy_bigquery/_types.py
12
+ sqlalchemy_bigquery/_versions_helpers.py
12
13
  sqlalchemy_bigquery/base.py
13
14
  sqlalchemy_bigquery/geography.py
14
15
  sqlalchemy_bigquery/parse_url.py
@@ -39,6 +40,7 @@ tests/unit/__init__.py
39
40
  tests/unit/conftest.py
40
41
  tests/unit/fauxdbi.py
41
42
  tests/unit/test__struct.py
43
+ tests/unit/test_alembic.py
42
44
  tests/unit/test_catalog_functions.py
43
45
  tests/unit/test_comments.py
44
46
  tests/unit/test_compiler.py
@@ -66,6 +66,10 @@ def test_alembic_scenario(alembic_table):
66
66
  table mods within a short time.
67
67
  """
68
68
  from alembic import op
69
+ from sqlalchemy_bigquery.base import SqlalchemyBigqueryImpl
70
+
71
+ # Register the BigQuery Implementation to test the customized methods.
72
+ op.implementation_for(SqlalchemyBigqueryImpl)
69
73
 
70
74
  assert alembic_table("account") is None
71
75
 
@@ -100,9 +104,11 @@ def test_alembic_scenario(alembic_table):
100
104
  "account", Column("last_transaction_date", DateTime, comment="when updated")
101
105
  )
102
106
 
107
+ # Tests customized visit_column_name()
108
+ op.alter_column("account", "name", new_column_name="friendly_name")
103
109
  assert alembic_table("account", "schema") == [
104
110
  SchemaField("id", "INTEGER", "REQUIRED"),
105
- SchemaField("name", "STRING(50)", "REQUIRED", description="The name"),
111
+ SchemaField("friendly_name", "STRING(50)", "REQUIRED", description="The name"),
106
112
  SchemaField("description", "STRING(200)"),
107
113
  SchemaField("last_transaction_date", "DATETIME", description="when updated"),
108
114
  ]
@@ -131,7 +137,7 @@ def test_alembic_scenario(alembic_table):
131
137
  assert alembic_table("account") is None
132
138
  assert alembic_table("accounts", "schema") == [
133
139
  SchemaField("id", "INTEGER", "REQUIRED"),
134
- SchemaField("name", "STRING(50)", "REQUIRED", description="The name"),
140
+ SchemaField("friendly_name", "STRING(50)", "REQUIRED", description="The name"),
135
141
  SchemaField("description", "STRING(200)"),
136
142
  SchemaField("last_transaction_date", "DATETIME", description="when updated"),
137
143
  ]
@@ -162,6 +168,7 @@ def test_alembic_scenario(alembic_table):
162
168
  # if allowed by BigQuery's type coercion rules
163
169
  op.create_table("identifiers", Column("id", Integer))
164
170
 
171
+ # Tests customized visit_column_type()
165
172
  op.alter_column("identifiers", "id", type_=Numeric)
166
173
  assert alembic_table("identifiers", "schema") == [SchemaField("id", "NUMERIC")]
167
174
 
@@ -561,7 +561,16 @@ def test_dml(engine, session, table_dml):
561
561
  assert len(result) == 0
562
562
 
563
563
 
564
- @pytest.mark.parametrize("time_partitioning_field", ["timestamp_c", "date_c"])
564
+ @pytest.mark.parametrize(
565
+ "time_partitioning_field",
566
+ [
567
+ ("timestamp_c"),
568
+ ("datetime_c"),
569
+ # Fails because python-bigquery TimePartitioning.type_ defaults to "DAY", but
570
+ # the DATE_TRUNC() function only allows "MONTH"/"YEAR"
571
+ pytest.param("date_c", marks=[pytest.mark.xfail]),
572
+ ],
573
+ )
565
574
  def test_create_table(engine, bigquery_dataset, time_partitioning_field):
566
575
  meta = MetaData()
567
576
  Table(
@@ -0,0 +1,37 @@
1
+ # Copyright (c) 2021 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
+ from alembic.ddl.base import ColumnName, ColumnType
21
+ from sqlalchemy import Integer
22
+
23
+
24
+ def test_alter_table_rename_column_bigquery(ddl_compiler):
25
+ from sqlalchemy_bigquery.base import visit_column_name
26
+
27
+ column = ColumnName(name="t", column_name="a", newname="b")
28
+ res = visit_column_name(element=column, compiler=ddl_compiler)
29
+ assert res == "ALTER TABLE `t` RENAME COLUMN `a` TO `b`"
30
+
31
+
32
+ def test_alter_column_new_type_bigquery(ddl_compiler):
33
+ from sqlalchemy_bigquery.base import visit_column_type
34
+
35
+ column = ColumnType(name="t", column_name="a", type_=Integer())
36
+ res = visit_column_type(element=column, compiler=ddl_compiler)
37
+ assert res == "ALTER TABLE `t` ALTER COLUMN `a` SET DATA TYPE INT64"
@@ -417,3 +417,42 @@ def test_complex_grouping_ops_vs_nested_grouping_ops(
417
417
  )
418
418
 
419
419
  assert found_sql == expected_sql
420
+
421
+
422
+ def test_label_compiler(faux_conn, metadata):
423
+ class CustomLower(sqlalchemy.sql.functions.FunctionElement):
424
+ name = "custom_lower"
425
+
426
+ @sqlalchemy.ext.compiler.compiles(CustomLower)
427
+ def compile_custom_intersect(element, compiler, **kwargs):
428
+ if compiler.dialect.name != "bigquery":
429
+ # We only test with the BigQuery dialect, so this should never happen.
430
+ raise sqlalchemy.exc.CompileError( # pragma: NO COVER
431
+ f"custom_lower is not supported for dialect {compiler.dialect.name}"
432
+ )
433
+
434
+ clauses = list(element.clauses)
435
+ field = compiler.process(clauses[0], **kwargs)
436
+ return f"LOWER({field})"
437
+
438
+ table1 = setup_table(
439
+ faux_conn,
440
+ "table1",
441
+ metadata,
442
+ sqlalchemy.Column("foo", sqlalchemy.String),
443
+ sqlalchemy.Column("bar", sqlalchemy.Integer),
444
+ )
445
+
446
+ lower_foo = CustomLower(table1.c.foo).label("some_label")
447
+ q = (
448
+ sqlalchemy.select(lower_foo, sqlalchemy.func.max(table1.c.bar))
449
+ .select_from(table1)
450
+ .group_by(lower_foo)
451
+ )
452
+ expected_sql = (
453
+ "SELECT LOWER(`table1`.`foo`) AS `some_label`, max(`table1`.`bar`) AS `max_1` \n"
454
+ "FROM `table1` GROUP BY `some_label`"
455
+ )
456
+
457
+ found_sql = q.compile(faux_conn).string
458
+ assert found_sql == expected_sql
@@ -104,111 +104,161 @@ def test_table_clustering_fields_dialect_option_type_error(faux_conn):
104
104
  )
105
105
 
106
106
 
107
- def test_table_time_partitioning_dialect_option(faux_conn):
108
- # expect table creation to fail as SQLite does not support partitioned tables
109
- with pytest.raises(sqlite3.OperationalError):
110
- setup_table(
111
- faux_conn,
112
- "some_table",
113
- sqlalchemy.Column("id", sqlalchemy.Integer),
114
- sqlalchemy.Column("createdAt", sqlalchemy.DateTime),
115
- bigquery_time_partitioning=TimePartitioning(),
116
- )
107
+ @pytest.mark.parametrize(
108
+ "column_dtype,time_partitioning_type,func_name",
109
+ [
110
+ # DATE dtype
111
+ pytest.param(
112
+ sqlalchemy.DATE,
113
+ TimePartitioningType.HOUR, # Only MONTH/YEAR are permitted in BigQuery
114
+ "DATE_TRUNC",
115
+ marks=pytest.mark.xfail,
116
+ ),
117
+ pytest.param(
118
+ sqlalchemy.DATE,
119
+ TimePartitioningType.DAY, # Only MONTH/YEAR are permitted in BigQuery
120
+ "DATE_TRUNC",
121
+ marks=pytest.mark.xfail,
122
+ ),
123
+ (sqlalchemy.DATE, TimePartitioningType.MONTH, "DATE_TRUNC"),
124
+ (sqlalchemy.DATE, TimePartitioningType.YEAR, "DATE_TRUNC"),
125
+ # TIMESTAMP dtype
126
+ (sqlalchemy.TIMESTAMP, TimePartitioningType.HOUR, "TIMESTAMP_TRUNC"),
127
+ (sqlalchemy.TIMESTAMP, TimePartitioningType.DAY, "TIMESTAMP_TRUNC"),
128
+ (sqlalchemy.TIMESTAMP, TimePartitioningType.MONTH, "TIMESTAMP_TRUNC"),
129
+ (sqlalchemy.TIMESTAMP, TimePartitioningType.YEAR, "TIMESTAMP_TRUNC"),
130
+ # DATETIME dtype
131
+ (sqlalchemy.DATETIME, TimePartitioningType.HOUR, "DATETIME_TRUNC"),
132
+ (sqlalchemy.DATETIME, TimePartitioningType.DAY, "DATETIME_TRUNC"),
133
+ (sqlalchemy.DATETIME, TimePartitioningType.MONTH, "DATETIME_TRUNC"),
134
+ (sqlalchemy.DATETIME, TimePartitioningType.YEAR, "DATETIME_TRUNC"),
135
+ # TimePartitioning.type_ == None
136
+ (sqlalchemy.DATETIME, None, "DATETIME_TRUNC"),
137
+ ],
138
+ )
139
+ def test_table_time_partitioning_given_field_and_type__dialect_options(
140
+ faux_conn, column_dtype, time_partitioning_type, func_name
141
+ ):
142
+ """NOTE: Expect table creation to fail as SQLite does not support
143
+ partitioned tables, despite that, we are still able to test the generation
144
+ of SQL statements.
117
145
 
118
- assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
119
- "CREATE TABLE `some_table` ( `id` INT64, `createdAt` DATETIME )"
120
- " PARTITION BY DATE_TRUNC(_PARTITIONDATE, DAY)"
121
- )
146
+ Each parametrization ensures that the appropriate function is generated
147
+ depending on whether the column datatype is DATE, TIMESTAMP, DATETIME and
148
+ whether the TimePartitioningType is HOUR, DAY, MONTH, YEAR.
122
149
 
150
+ `DATE_TRUNC` only returns a result if TimePartitioningType is DAY, MONTH,
151
+ YEAR. BigQuery cannot partition on DATE by HOUR, so that is expected to
152
+ xfail.
123
153
 
124
- def test_table_require_partition_filter_dialect_option(faux_conn):
125
- # expect table creation to fail as SQLite does not support partitioned tables
126
- with pytest.raises(sqlite3.OperationalError):
127
- setup_table(
128
- faux_conn,
129
- "some_table",
130
- sqlalchemy.Column("createdAt", sqlalchemy.DateTime),
131
- bigquery_time_partitioning=TimePartitioning(field="createdAt"),
132
- bigquery_require_partition_filter=True,
133
- )
154
+ A distinguishing characteristic of this test is we provide an argument to
155
+ the TimePartitioning class for both field and type_.
134
156
 
135
- assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
136
- "CREATE TABLE `some_table` ( `createdAt` DATETIME )"
137
- " PARTITION BY DATE_TRUNC(createdAt, DAY)"
138
- " OPTIONS(require_partition_filter=true)"
139
- )
157
+ Special case: IF time_partitioning_type is None, the __init__() in the
158
+ TimePartitioning class will overwrite it with TimePartitioningType.DAY as
159
+ the default.
160
+ """
140
161
 
162
+ if time_partitioning_type is None:
163
+ time_partitioning_type = TimePartitioningType.DAY
141
164
 
142
- def test_table_time_partitioning_with_field_dialect_option(faux_conn):
143
- # expect table creation to fail as SQLite does not support partitioned tables
144
165
  with pytest.raises(sqlite3.OperationalError):
145
166
  setup_table(
146
167
  faux_conn,
147
168
  "some_table",
148
169
  sqlalchemy.Column("id", sqlalchemy.Integer),
149
- sqlalchemy.Column("createdAt", sqlalchemy.DateTime),
150
- bigquery_time_partitioning=TimePartitioning(field="createdAt"),
170
+ sqlalchemy.Column("createdAt", column_dtype),
171
+ bigquery_time_partitioning=TimePartitioning(
172
+ field="createdAt", type_=time_partitioning_type
173
+ ),
151
174
  )
152
175
 
153
- assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
154
- "CREATE TABLE `some_table` ( `id` INT64, `createdAt` DATETIME )"
155
- " PARTITION BY DATE_TRUNC(createdAt, DAY)"
176
+ result = " ".join(faux_conn.test_data["execute"][-1][0].strip().split())
177
+ expected = (
178
+ f"CREATE TABLE `some_table` ( `id` INT64, `createdAt` {column_dtype.__visit_name__} )"
179
+ f" PARTITION BY {func_name}(createdAt, {time_partitioning_type})"
156
180
  )
181
+ assert result == expected
157
182
 
158
183
 
159
- def test_table_time_partitioning_by_month_dialect_option(faux_conn):
160
- # expect table creation to fail as SQLite does not support partitioned tables
161
- with pytest.raises(sqlite3.OperationalError):
162
- setup_table(
163
- faux_conn,
164
- "some_table",
165
- sqlalchemy.Column("id", sqlalchemy.Integer),
166
- sqlalchemy.Column("createdAt", sqlalchemy.DateTime),
167
- bigquery_time_partitioning=TimePartitioning(
168
- field="createdAt",
169
- type_=TimePartitioningType.MONTH,
170
- ),
171
- )
184
+ def test_table_time_partitioning_given_field_but_no_type__dialect_option(faux_conn):
185
+ """Expect table creation to fail as SQLite does not support partitioned tables
172
186
 
173
- assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
174
- "CREATE TABLE `some_table` ( `id` INT64, `createdAt` DATETIME )"
175
- " PARTITION BY DATE_TRUNC(createdAt, MONTH)"
176
- )
187
+ Confirms that if the column datatype is DATETIME but no TimePartitioning.type_
188
+ has been supplied, the system will default to DAY.
177
189
 
190
+ A distinguishing characteristic of this test is we provide an argument to
191
+ the TimePartitioning class for field but not type_.
192
+ """
178
193
 
179
- def test_table_time_partitioning_with_timestamp_dialect_option(faux_conn):
180
- # expect table creation to fail as SQLite does not support partitioned tables
181
194
  with pytest.raises(sqlite3.OperationalError):
182
195
  setup_table(
183
196
  faux_conn,
184
197
  "some_table",
185
198
  sqlalchemy.Column("id", sqlalchemy.Integer),
186
- sqlalchemy.Column("createdAt", sqlalchemy.TIMESTAMP),
199
+ sqlalchemy.Column("createdAt", sqlalchemy.DateTime),
187
200
  bigquery_time_partitioning=TimePartitioning(field="createdAt"),
188
201
  )
189
-
190
- assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
191
- "CREATE TABLE `some_table` ( `id` INT64, `createdAt` TIMESTAMP )"
192
- " PARTITION BY TIMESTAMP_TRUNC(createdAt, DAY)"
202
+ result = " ".join(faux_conn.test_data["execute"][-1][0].strip().split())
203
+ expected = (
204
+ "CREATE TABLE `some_table` ( `id` INT64, `createdAt` DATETIME )"
205
+ " PARTITION BY DATETIME_TRUNC(createdAt, DAY)"
193
206
  )
207
+ assert result == expected
194
208
 
195
209
 
196
- def test_table_time_partitioning_with_date_dialect_option(faux_conn):
197
- # expect table creation to fail as SQLite does not support partitioned tables
210
+ @pytest.mark.parametrize(
211
+ "column_dtype,time_partitioning_type",
212
+ [
213
+ pytest.param(
214
+ sqlalchemy.DATE,
215
+ TimePartitioningType.HOUR,
216
+ marks=pytest.mark.xfail,
217
+ ),
218
+ (sqlalchemy.DATE, TimePartitioningType.DAY),
219
+ (sqlalchemy.DATE, TimePartitioningType.MONTH),
220
+ (sqlalchemy.DATE, TimePartitioningType.YEAR),
221
+ ],
222
+ )
223
+ def test_table_time_partitioning_given_type__but_no_field_dialect_option(
224
+ faux_conn,
225
+ column_dtype,
226
+ time_partitioning_type,
227
+ ):
228
+ """NOTE: Expect table creation to fail as SQLite does not support
229
+ partitioned tables, despite that, we are still able to test the generation
230
+ of SQL statements
231
+
232
+ If the `field` argument to TimePartitioning() is not provided, it defaults to
233
+ None. That causes the pseudocolumn "_PARTITIONDATE" to be used by default as
234
+ the column to partition by.
235
+
236
+ _PARTITIONTIME only returns a result if TimePartitioningType is DAY, MONTH,
237
+ YEAR. BigQuery cannot partition on _PARTITIONDATE by HOUR, so that is
238
+ expected to xfail.
239
+
240
+ A distinguishing characteristic of this test is we provide an argument to
241
+ the TimePartitioning class for type_ but not field.
242
+ """
243
+
198
244
  with pytest.raises(sqlite3.OperationalError):
199
245
  setup_table(
200
246
  faux_conn,
201
247
  "some_table_2",
202
248
  sqlalchemy.Column("id", sqlalchemy.Integer),
203
- sqlalchemy.Column("createdAt", sqlalchemy.DATE),
204
- bigquery_time_partitioning=TimePartitioning(field="createdAt"),
249
+ sqlalchemy.Column("createdAt", column_dtype),
250
+ bigquery_time_partitioning=TimePartitioning(type_=time_partitioning_type),
205
251
  )
206
252
 
207
253
  # confirm that the following code creates the correct SQL string
208
- assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
209
- "CREATE TABLE `some_table_2` ( `id` INT64, `createdAt` DATE )"
210
- " PARTITION BY createdAt"
254
+ result = " ".join(faux_conn.test_data["execute"][-1][0].strip().split())
255
+
256
+ # We need two versions of expected depending on whether we use _PARTITIONDATE
257
+ expected = (
258
+ f"CREATE TABLE `some_table_2` ( `id` INT64, `createdAt` {column_dtype.__visit_name__} )"
259
+ f" PARTITION BY _PARTITIONDATE"
211
260
  )
261
+ assert result == expected
212
262
 
213
263
 
214
264
  def test_table_time_partitioning_dialect_option_partition_expiration_days(faux_conn):
@@ -227,7 +277,7 @@ def test_table_time_partitioning_dialect_option_partition_expiration_days(faux_c
227
277
 
228
278
  assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
229
279
  "CREATE TABLE `some_table` ( `createdAt` DATETIME )"
230
- " PARTITION BY DATE_TRUNC(createdAt, DAY)"
280
+ " PARTITION BY DATETIME_TRUNC(createdAt, DAY)"
231
281
  " OPTIONS(partition_expiration_days=0.25)"
232
282
  )
233
283
 
@@ -400,13 +450,16 @@ def test_table_all_dialect_option(faux_conn):
400
450
  ),
401
451
  )
402
452
 
403
- assert " ".join(faux_conn.test_data["execute"][-1][0].strip().split()) == (
453
+ result = " ".join(faux_conn.test_data["execute"][-1][0].strip().split())
454
+ expected = (
404
455
  "CREATE TABLE `some_table` ( `id` INT64, `country` STRING, `town` STRING, `createdAt` DATETIME )"
405
- " PARTITION BY DATE_TRUNC(createdAt, DAY)"
456
+ " PARTITION BY DATETIME_TRUNC(createdAt, DAY)"
406
457
  " CLUSTER BY country, town"
407
458
  " OPTIONS(partition_expiration_days=30.0, expiration_timestamp=TIMESTAMP '2038-01-01 00:00:00+00:00', require_partition_filter=true, default_rounding_mode='ROUND_HALF_EVEN')"
408
459
  )
409
460
 
461
+ assert result == expected
462
+
410
463
 
411
464
  def test_validate_friendly_name_value_type(ddl_compiler):
412
465
  # expect option value to be transformed as a string expression
@@ -8,14 +8,14 @@ sqlalchemy<3.0.0dev,>=1.4.16
8
8
  alembic
9
9
 
10
10
  [all]
11
- pytz
12
- google-cloud-bigquery-storage<3.0.0dev,>=2.0.0
13
- alembic
11
+ GeoAlchemy2
12
+ shapely
14
13
  grpcio<2.0dev,>=1.47.0
14
+ pytz
15
15
  packaging
16
16
  pyarrow>=3.0.0
17
- GeoAlchemy2
18
- shapely
17
+ google-cloud-bigquery-storage<3.0.0dev,>=2.0.0
18
+ alembic
19
19
 
20
20
  [all:python_version >= "3.11"]
21
21
  grpcio<2.0dev,>=1.49.1