-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Make recursive queries efficient #1122
Comments
Can you give some examples of the JSON parsing? It might be possible to solve that directly without generic recursive query support.
|
I'm not really sure why presto doesn't support it. According to : Isn't presto must support SQL standard? |
Here is a recursive query that I use to create a date dimension table. I would love to see it work in Presto!
|
https://docs.oracle.com/cd/B28359_01/server.111/b28286/queries003.htm#SQLRF52315 have some good examples too, classic example is grandfather id, ie get the manager id of each employee up the chain |
I asked a question in the Slack channel that I think could be solved with recursive queries: If
Poking around led me to this: https://stackoverflow.com/questions/52798009/how-to-use-result-of-previous-calculated-row-based-on-a-condition-in-sql I think recursive CTEs are what I need... I assume this is a very large feature? Obviously not SQL standard, but if there was a way to use the current value of the sum inside a |
I might (depending on what happens to #3535) have a related use cases: I'm adding standard SQL |
In order to implement recursive CTEs, we need support for:
Here's a short analysis of how recursive CTEs work. For a query such as:
The query is semantically equivalent to doing the following steps, where
The result of the query is the If we were to fully expand the query based on current Presto capabilities, the query would turn into:
We end up with N executions of the base query (instead of, ideally, just 1) and
The query could then be executed according to this sequence:
|
Alternative implementations could use a single temp table with a I.e, the i'th query is Or, one could have two temp tables, a working table and an intermediary table and empty the intermediary after each iteration. |
Even the expanded format @martint suggested above is not working for me. Beyond the second UNION ALL, I get an error "Column 'n' cannot be resolved". |
@tech-tendai you can reach out for help on the |
It would be really nice if Presto supported recursive queries.
A potential use case would be to dynamically parse generic json strings to get all nested and unnested json keys.
The text was updated successfully, but these errors were encountered: