Skip to content

Commit 5f772c8

Browse files
committed
fix: Support partitioning by DATE or Date
1 parent b54bdde commit 5f772c8

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

sqlalchemy_bigquery/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ def _process_time_partitioning(
838838
field = time_partitioning.field
839839
if isinstance(
840840
table.columns[time_partitioning.field].type,
841-
sqlalchemy.sql.sqltypes.DATE,
841+
(sqlalchemy.sql.sqltypes.DATE, sqlalchemy.sql.sqltypes.Date),
842842
):
843843
return f"PARTITION BY {field}"
844844
elif isinstance(

tests/unit/test_table_options.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,15 @@ def test_table_time_partitioning_with_timestamp_dialect_option(faux_conn):
193193
)
194194

195195

196-
def test_table_time_partitioning_with_date_dialect_option(faux_conn):
196+
@pytest.mark.parametrize("date_type", [sqlalchemy.DATE, sqlalchemy.Date])
197+
def test_table_time_partitioning_with_date_dialect_option(faux_conn, date_type):
197198
# expect table creation to fail as SQLite does not support partitioned tables
198199
with pytest.raises(sqlite3.OperationalError):
199200
setup_table(
200201
faux_conn,
201202
"some_table_2",
202203
sqlalchemy.Column("id", sqlalchemy.Integer),
203-
sqlalchemy.Column("createdAt", sqlalchemy.DATE),
204+
sqlalchemy.Column("createdAt", date_type),
204205
bigquery_time_partitioning=TimePartitioning(field="createdAt"),
205206
)
206207

0 commit comments

Comments
 (0)