Skip to content

fix(sqlalchemy-bigquery): compile func.now() to CURRENT_TIMESTAMP - #18994

Merged
parthea merged 1 commit into
googleapis:mainfrom
abhishekacharya200:fix-sqlalchemy-bigquery-func-now
Nov 5, 2026
Merged

parthea merged 1 commit into
googleapis:mainfrom
abhishekacharya200:fix-sqlalchemy-bigquery-func-now

Conversation

@abhishekacharya200

Copy link
Copy Markdown
Contributor

Fixes #15762

BigQuery has no NOW() function, but func.now() compiled to now() with this dialect, so queries and server_default=func.now() columns failed in BigQuery.

This adds visit_now_func to BigQueryCompiler so func.now() compiles to CURRENT_TIMESTAMP. That is what func.current_timestamp() already compiles to here, and it matches how the SQLite, MSSQL and Oracle dialects handle now().

Added test_now_compiles_to_current_timestamp in tests/unit/test_compiler.py, which fails on main (SELECT now() AS ts) and passes with this change. The package's unit tests pass locally, and the noxfile's ruff 0.14.14 checks, flake8 and black report nothing on the changed files.

BigQuery has no NOW() function, so queries and server defaults that
use func.now() failed. Compile it to CURRENT_TIMESTAMP instead, the
same way other SQLAlchemy dialects do.

Fixes googleapis#15762
@abhishekacharya200
abhishekacharya200 requested review from a team as code owners November 5, 2026 07:56
@abhishekacharya200
abhishekacharya200 requested review from sindhuvy and removed request for a team November 5, 2026 07:56

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for compiling the SQL NOW() function to CURRENT_TIMESTAMP in the BigQuery dialect, since BigQuery does not natively support NOW(). A corresponding unit test has also been added to verify this behavior. There are no review comments, and I have no feedback to provide.

@parthea parthea added kokoro:force-run Add this label to force Kokoro to re-run the tests. kokoro:run Add this label to force Kokoro to re-run the tests. labels Nov 5, 2026
@yoshi-kokoro yoshi-kokoro removed kokoro:run Add this label to force Kokoro to re-run the tests. kokoro:force-run Add this label to force Kokoro to re-run the tests. labels Nov 5, 2026
@parthea
parthea enabled auto-merge (squash) November 5, 2026 17:39
@parthea
parthea merged commit 07df830 into googleapis:main Nov 5, 2026
54 of 55 checks passed
parthea added a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.18.0](sqlalchemy-bigquery-v1.17.3...sqlalchemy-bigquery-v1.18.0)
(2026-11-12)


### Features

* **sqlalchemy-bigquery:** support BigQuery SAFE_CAST and SQLAlchemy 2.0
try_cast
([#18953](#18953))
([931968b](931968b))
* support Python 3.15
([8fceef4](8fceef4))


### Bug Fixes

* **sqlalchemy-bigquery:** compile func.now() to CURRENT_TIMESTAMP
([#18994](#18994))
([07df830](07df830))
* **sqlalchemy-bigquery:** restore String bindparam type for GeoAlchemy2
0.21.0
([#18985](#18985))
([edc4372](edc4372))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

func.now() returns now() which is not supported function in BigQuery

4 participants