-
Notifications
You must be signed in to change notification settings - Fork 57
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
Can we have a api to separate the complex multi-table join query to sub-queries? #48
Comments
@RemilYoucef has made a pull request that may do some of the work you are looking for: #26. The |
I think about this more often than is useful: By converting (multi-table) joins to subqueries, we can translate queries to document stores and hierarchical databases. |
A similar feature would be separating subqueries into common table expressions, making them more readable. Ex. select a,b converts to: with t as ( ,v as ( select a,b from t join v on t.id=v.id Presumably, one path would be converting the JSON subquery output to a JSON "with" output, then "formatting" to sql. Any suggestions on where I would start to implement this? |
Your suggestion goes along the lines of my own thinking. I have a project that transpiles SQL into other query languages, it covers many simple use cases, but it is mostly incomplete. What remains is the feature you propose (well, the reverse mapping from subquery-form to join-form).
So, how should you proceed? There are two options:
I am willing to collaborate with you on this project if you are willing to attempt the heavy lifting: It is best if this project has it's own repo. Make one, and tell me where it is, I can setup the test suite, and add test cases. I can also provide feedback in reviews, or be around to discuss ideas. |
For a simple join query blow:
q = "SELECT Orders.OrderID, Customers.CustomerName FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID;"
we hope it can separate something similar:
"Orders": "SELECT OrderID, CustomerID FROM Orders",
"Customers": "SELECT CustomerName, CustomerID FROM Customers"
The text was updated successfully, but these errors were encountered: