You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a great idea. Unlike a few other engines, ZetaSQL has a full parser that's easy to import. I'll need to play around with it to make sure that it builds on all our supported platforms.
Reacted by Steve Coffman, Burak Karakan, Shogo Iwano, Yuki Ito, John Wang, Masahiro Wakame, Dan Gurney, Bill Sorensen, ginokent, Sho Minagawa and 5 more
@kyleconroy how hard would you say this is given we could reuse the ZetaSQL parser? I would really like to have Spanner support with SQLc. And would you accept a PR if I have some time to spare on this?
Hum, I see you're trying to remove CGO dependencies to be able to run on Windows and golang ZetaSQL is a CGO dependency, so this probably won't fly ...
Currently, I believe memefish is the most feature-complete parser for Spanner GoogleSQL.
In addition, memefish provides all the necessary functionality to implement a Spanner GoogleSQL engine for sqlc.
FYI:
I've created a proof-of-concept implementation for sqlc Spanner support by vibe-coding.
If there is interest, I'm happy to reimplement it to fit your contribution policy.
Disclaimer: I'm a contributor to memefish.
Reacted by nnaka2992, Alexandre Thenorio, Fredrik Averpil, Tim Tattersall, bramoudith-sc and Masahiro Wakame
Reacted by Alexandre Thenorio, Fredrik Averpil and Masahiro Wakame
Seeing if we can re-envigorate this thread - there have been a few changes to GoogleSQL support since this was raised.
Usage
I primarily use GoogleSQL for Spanner, though this would also be useful for BigQuery users. The main functionality of sqlc I utilise is the sqlc generate (not using sqlc cloud). At this stage, not making much use out of the sqlc analysis functionality.
Would be awesome if this could be incrementally released starting with the generate functionality and following up with analysis integration.
Useful Libraries
Since the last update on this issue, GoogleSQL has consolidated with ZetaSQL
If you'd like to try out a very early version of BigQuery and Spanner support, you can build sqlc from main and use the new sqlc parse and sqlc analyze commands. I'll be wiring it up to code gen soon.
$ echo'CREATE TABLE MyFirstTable ( Id INT64 GENERATED BY DEFAULT AS IDENTITY (START COUNTER WITH 11000), Name STRING(MAX),) PRIMARY KEY (Id)'| mise x go:github.com/sqlc-dev/sqlc/cmd/sqlc@main -- sqlc parse --dialect googlesql
Error: parse error: Syntax error: Expected keyword WITH but got identifier "COUNTER" [at 2:52]
spanner_legacy_ddl.test does not track the current Spanner DDL syntax, so many constructs will need to be implemented by referring to other sources, such as the Cloud Spanner emulator.
@apstndb I believe this should now be fixed, as I've expanded statement support in our parser. Please try out the code generation on main, which was added in #4621
Activity
kyleconroy commentedon Mar 24, 2022
This is a great idea. Unlike a few other engines, ZetaSQL has a full parser that's easy to import. I'll need to play around with it to make sure that it builds on all our supported platforms.
[-]Support GCP Cloud Spanner and BigQuery via ZetaSQL dialect[/-][+]Cloud Spanner and BigQuery support[/+]kyleconroy commentedon Sep 22, 2023
I removed the accepted label as we aren't planning on working on this in the short term. Still excited about it!
[-]Cloud Spanner and BigQuery support[/-][+]Add Cloud Spanner and BigQuery support[/+]matdurand commentedon Mar 20, 2025
@kyleconroy how hard would you say this is given we could reuse the ZetaSQL parser? I would really like to have Spanner support with SQLc. And would you accept a PR if I have some time to spare on this?
matdurand commentedon Mar 20, 2025
Hum, I see you're trying to remove CGO dependencies to be able to run on Windows and golang ZetaSQL is a CGO dependency, so this probably won't fly ...
matdurand commentedon Mar 21, 2025
Here is a potential non CGO replacement for the query parser. It's probably just for Spanner though, not BigQuery
https://github.com/cloudspannerecosystem/memefish
feat: Add Cloud Spanner engine PoC for sqlc
apstndb commentedon Aug 7, 2025
ZetaSQL is not only non-CGO; it also cannot be used to parse Spanner GoogleSQL DDL because Spanner GoogleSQL DDL is not compatible with ZetaSQL DDL. For example, cloud-spanner-emulator uses ZetaSQL for query/DML parsing, but relies on its own DDL parser for DDL operations:
https://github.com/GoogleCloudPlatform/cloud-spanner-emulator/tree/master/backend/schema/parser
Currently, I believe memefish is the most feature-complete parser for Spanner GoogleSQL.
In addition, memefish provides all the necessary functionality to implement a Spanner GoogleSQL engine for sqlc.
FYI:
I've created a proof-of-concept implementation for sqlc Spanner support by vibe-coding.
If there is interest, I'm happy to reimplement it to fit your contribution policy.
Disclaimer: I'm a contributor to memefish.
bramoudith-sc commentedon Oct 22, 2025
@apstndb would you mind creating a pull request?
apstndb commentedon Oct 22, 2025
@bramoudith-sc
I think this project doesn't accept a PR of new engine currently.
timtatt commentedon Jun 13, 2026
Seeing if we can re-envigorate this thread - there have been a few changes to GoogleSQL support since this was raised.
Usage
I primarily use GoogleSQL for Spanner, though this would also be useful for BigQuery users. The main functionality of
sqlcI utilise is the sqlc generate (not using sqlc cloud). At this stage, not making much use out of the sqlc analysis functionality.Would be awesome if this could be incrementally released starting with the generate functionality and following up with analysis integration.
Useful Libraries
Since the last update on this issue, GoogleSQL has consolidated with ZetaSQL
GoogleSQL Documentation
Happy to Help
Please let me know how I can help with implementing this functionality, happy to submit a PR or doing some alpha testing!
kyleconroy commentedon Aug 18, 2026
If you'd like to try out a very early version of BigQuery and Spanner support, you can build sqlc from main and use the new sqlc parse and sqlc analyze commands. I'll be wiring it up to code gen soon.
apstndb commentedon Aug 18, 2026
@kyleconroy
Great work.
In general, I think building an implementation that passes all tests based on the
.testfiles ingoogle/googlesqlis a good approach.However, there seems to be one unresolved issue with this approach: Spanner GoogleSQL DDL is, in fact, not the same as GoogleSQL DDL.
https://docs.cloud.google.com/spanner/docs/migrating-primary-keys?hl=en#migrate-bit-reversed-key-columns
spanner_legacy_ddl.testdoes not track the current Spanner DDL syntax, so many constructs will need to be implemented by referring to other sources, such as the Cloud Spanner emulator.kyleconroy commentedon Oct 14, 2026
@apstndb I believe this should now be fixed, as I've expanded statement support in our parser. Please try out the code generation on main, which was added in #4621