-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-12048: [Rust][DataFusion] Support Common Table Expressions #9776
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
Conversation
…rence, add more tests
jorgecarleitao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @Dandandan !
|
Thank you for this @Dandandan ! I plan to review this carefully tomorrow |
| let logical_plan = self.query_to_plan_with_alias( | ||
| &cte.query, | ||
| Some(cte.alias.name.value.clone()), | ||
| &mut ctes.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This clone is now relatively inefficient for very long and/or deep ctes.
Solutions I see for this problem.
- use an immutable HashMap (O(1) clone, easier to program), example: https://docs.rs/im/15.0.0/im/struct.HashMap.html
- use something like "frames", e.g.
Vec<HashMap<String, LogicalPlan>>-> when looking up a reference first look up level 0, level-1, level -2, etc. - cleanup the variables before returning (removing / replacing the added references)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the frames idea makes the most sense to me -- namely a stack
We can handle it in the future if/when it shows itself to be a problem
| let logical_plan = self.query_to_plan_with_alias( | ||
| &cte.query, | ||
| Some(cte.alias.name.value.clone()), | ||
| &mut ctes.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the frames idea makes the most sense to me -- namely a stack
We can handle it in the future if/when it shows itself to be a problem
… of SQL features @Dandandan added the feature in #9776, updating docs to keep pace Closes #9795 from alamb/alamb/CTE Authored-by: Andrew Lamb <[email protected]> Signed-off-by: Andrew Lamb <[email protected]>
This adds support for CTE syntax:
Before this PR, the CTE syntax was ignored.
This PR supports CTEs referening a previous CTE within the same query (but no forward references)