from Hacker News

New PostgreSQL Interface for Cloud Spanner

by aleyan on 10/12/21, 8:38 PM with 41 comments

  • by wmitty on 10/12/21, 10:13 PM

    The Cloud Spanner SQL frontend/analyzer has been open sourced by google as ZetaSQL. https://github.com/google/zetasql

    It is amazingly good.

    You give it textual SQL (+ schema + all your function definitions) and it returns a really clean logical query plan. It is also happy to do this via a protobufs so you can use it from languages other than C++. It is also tested and documented up the wazoo. It has been such a pleasure to work with.

    Anyway, the big problem with ZetaSQL is that it is not a common SQL dialect.

    It seems that the only reasonable way to do this PostgreSQL interface for Cloud Spanner is to add a second parser (and other extensions) to ZetaSQL. If I am correct, I really really hope they open source that part of ZetaSQL as well - it would be a massive step forward for open source SQL tooling.

  • by orf on 10/12/21, 10:23 PM

    Looks awesome! A few data types not yet supported: https://cloud.google.com/spanner/docs/postgresql/data-types, like interval or array, which is a shame.

    Is just like to mention how awful the Google cloud docs are on a slow connection. Each link does some weird SPA bullshit that seems to take way too long, and you seem to often end up in an inconsistent state where refreshing the page takes you to a completely different article. Then pressing back seems to re-load the current page you are on whilst it does more SPA bullshit.

    Small, simple HTML doc pages that are fast to load please. Copy how AWS does it.

  • by ttul on 10/13/21, 12:01 AM

    Back in the dinosaur age, I built a WiFi hotspot billing system using PostgreSQL. MySQL had a larger following, but was less reliable and lacked transactions. PostgreSQL was a competitor to Oracle, which was seen as the undisputed leader for large-scale databases containing mission-critical business data.

    Fast-forward to 2021 and I am not surprised at all that PostgreSQL now seems to be taking over everywhere. The ethic of the PostgreSQL team seems to revolve around correctness and reliability rather than features and speed. I congratulate the team for sticking to their mettle all these years and achieving such success.

  • by the_duke on 10/12/21, 10:03 PM

    > the PostgreSQL interface implements a core subset of PostgreSQL data types and DDL syntax.

    > Familiarity and portability are the goals, not 100% compatibility

    So, is there a compatibility matrix?

    In general I see this as a good thing. It allows using Spanner without requiring a big rewrite should one want to migrate away from GC. Or using Spanner as a secondary data warehouse with the same queries.

    But both of those do require a high level of conformance.

  • by slownews45 on 10/12/21, 10:59 PM

    Wow - I did NOT see this coming.

    Crazy - and GREAT!

    Cloud Spanner in my mind was always "cool" - but I never saw myself understanding how to use it.

    I think for folks bridging from something like postgresql, this could also make spanner more accessible.

    My own use cases can all be handled so simply with postgresql I don't see needing the spanner scale, but for others perhaps valuable.

  • by da39a3ee on 10/12/21, 10:35 PM

    Is anyone able to comment on the extent to which Cloud Spanner and CockroachDB are in competition with each other? (CockroachDB is also wire-compatible with Postgres and originates as an implementation of something similar to Spanner)
  • by Diggsey on 10/13/21, 1:10 AM

    Spanner, CockroachDB and similar are really exciting, but the fact that none of them support stored procedures begs the question of whether it's inherently hard/impossible to do so in a distributed database, or whether that just hasn't been a priority...
  • by sciurus on 10/13/21, 10:58 AM

    > To enable PostgreSQL tools that don’t know anything about Spanner, the PostgreSQL interface also includes an open-source adapter that runs as a sidecar proxy, close to a client.

    I wonder why they decided to do this instead of building a postgres-compatible endpoint into the spanner service itself.

  • by ralusek on 10/13/21, 9:20 AM

    This is awesome, but what are the limitations? Unless I can use it with ORMs that I already tend to depend on (like Sequelize), it's probably a no-go. And I'm assuming no joins, or very limited left joins?
  • by thorum on 10/13/21, 4:58 AM

    That’s very cool. Does anyone know if there is a good list of other databases that include a PostgreSQL interface?
  • by bigbizisverywyz on 10/13/21, 12:29 PM

    I'm surprised people are applauding this. The net result of this support (and cockroach's) is that it will take mindshare away from Postgres which has worked hard for decades to build a loyal fanbase.

    It's also step 1 of the e.e.e playbook, not that I'm suggesting Google want to extinguish Postgres, but it's clearly aimed at building their market share at the expense of Postgres's.