-
Notifications
You must be signed in to change notification settings - Fork 222
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
Transpiling from SQL to PRQL #130
Comments
Update: this is currently not possible yet, but we are not far off. The |
A SQL -> PRQL transpiler would REALLY ease adoption for PRQL. Even if it had some disclaimers, it lowers a lot of barriers if a new user is trying to learn/adopt PRQL and could copy/paste a bunch of SQL queries. |
Using Apache Calcite for parsing queries and turning them into an AST could be an idea. Calcite is written in Java, though, and not in Rust. |
We'd likely use sqlparser-rs, which we currently use to represent SQL AST, and it builds the SQL string. |
This is a longer-term idea — but now we're using sqlparser to write SQL, we could also use it to read SQL and produce PRQL.
We'd need to write:
Display
implementations which convert PRQL AST to PRQL codeThis would be useful for people transitioning from SQL. At least initially, the main users are likely to be engineers who are frustrated by SQL because they've written a lot of it.
We wouldn't need to support all of SQL for it to be useful — there's a fairly small subset that's used a lot — and possibly a larger subset which we could implement with s-strings.
We also wouldn't need to automatically do things like variable "creation" (e.g. replacing
salary + payroll_tax + benefits_cost
withgross_cost
), which would be much more difficult (but great if we could!).The text was updated successfully, but these errors were encountered: