Skip to content

Switch query parser to pg_query.rs #620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mdashti opened this issue Oct 13, 2023 · 3 comments
Open

Switch query parser to pg_query.rs #620

mdashti opened this issue Oct 13, 2023 · 3 comments

Comments

@mdashti
Copy link
Contributor

mdashti commented Oct 13, 2023

Is your feature request related to a problem? Please describe.
Currently, pgcat is using sqlparser-rs to parse user queries. That's taken us to where we are today, which is great. However, sqlparser-rs does not correctly parse all PostgreSQL queries. There are already some open PRs to fix the known issues (e.g., apache/datafusion-sqlparser-rs#1000 and apache/datafusion-sqlparser-rs#1002), but it's not going to be 100% PG compatible.

Describe the solution you'd like
The closest to PostgreSQL parser that we can get is to use the PostgreSQL parser itself :)

Here's the maintained (extracted) C library: libpg_query, and here's its port to Rust (by pganalyze): pg_query.rs

I wanted to ask for everyone's opinion (especially the main pgcat maintainers) about changing our SQL parser from sqlparser-rs to pg_query.rs. If I see enough support for this change, I can put-together a PR for it.

@levkk
Copy link
Contributor

levkk commented Oct 13, 2023

I believe not only pg_query.rs is the most correct Postgres SQL parser but also it's faster than sqlparser. There is a draft PR by another contributor with that integration: #525

@mdashti
Copy link
Contributor Author

mdashti commented Oct 14, 2023

Thanks for the reference to PR #525. Cool stuff!

However, that PR only uses pg_query.rs without removing the current usages of sqlparser. I'll create a PR for that.

@KennyChenFight
Copy link

Just curious about any progress for this ?

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

No branches or pull requests

3 participants