uwdata / mosaic

An extensible framework for linking databases and interactive views.
https://idl.uw.edu/mosaic
Other
763 stars 47 forks source link

Query Parsing and Analysis #396

Open domoritz opened 3 months ago

domoritz commented 3 months ago

Currently query analysis is only possible when using Mosaic’s SQL builder methods, which maintain a structured representation of the query. While arbitrary query expressions are allowed, they are not analyzed. This project would develop a SQL parser in JavaScript that we can use to parse SQL text into a structured representation such as an AST. DuckDB already has a parser in the JSON extension.

domoritz commented 2 weeks ago

This could be super useful for #510 but we probably want to consider revising the SQL representation in mosaic first.

nicosuave commented 1 week ago

Depending on how wide you're looking to go with multi database support beyond the DuckDB multi database support for Postgres/MySQL, could use something like this. Seems like lots of dialects are implemented; I'm sure DuckDB isn't too far from Postgres. Not too sure of quality, but seems reasonable?

domoritz commented 5 days ago

Thanks for the link. I think we can make our lives a bit easier by generating SQL in different dialects from a structured format (which we already have in https://github.com/uwdata/mosaic/tree/main/packages/sql). But we need to make the current implementation more flexible.