▲ | skeptrune 5 days ago | |
>we need to ... understand SQL syntax using a parser, Rust ecosystem has a great library called pg_query I'm impressed both that the Rust ecosystem had the right library available and that it was high enough quality code for the author's team to use it as a reference for building their own additional functionality. | ||
▲ | craigkerstiens 5 days ago | parent | next [-] | |
Pgquery was created by the pganalyze team for their own purposes I believe initially for features like index recommendation tooling, but immediately planned as open source. It is indeed a very high quality project with the underlying C implementation having several wrappers that exist for a number of languages[1]. [1] https://github.com/pganalyze/libpg_query/blob/15-latest/READ... | ||
▲ | bri3d 5 days ago | parent | prev | next [-] | |
Oddly, it actually originates from the Ruby ecosystem - `pganalyze` initially created `libpg_query` to parse Postgres in Ruby. `libpg_query` in C does the "magic" of reformulating Postgres's query parser into an AST generator, and serializes the resulting AST into a Protobuf. Then, `pg_query` bridges that into Rust. | ||
▲ | levkk 5 days ago | parent | prev [-] | |
We're using it to rewrite queries too. It's a pretty cool library. |