-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-11433] [SQL] Cleanup the subquery name after eliminating subquery #9385
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1019,7 +1019,16 @@ class Analyzer( | |
| * scoping information for attributes and can be removed once analysis is complete. | ||
| */ | ||
| object EliminateSubQueries extends Rule[LogicalPlan] { | ||
| def apply(plan: LogicalPlan): LogicalPlan = plan transform { | ||
| def apply(plan: LogicalPlan): LogicalPlan = plan transformDown { | ||
| case Project(projectList, child: Subquery) => { | ||
| Project( | ||
| projectList.flatMap { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we simplify this to a map and remove the :: Nil we have in the two sub cases? since it seems we are always returning a single element list for every case so it should be ok as a map.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! I did the change based on your suggestion. : ) |
||
| case ar: AttributeReference if ar.qualifiers.contains(child.alias) => | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I use NamedExpression to replace AttributeReference? |
||
| ar.withQualifiers(ar.qualifiers.filter(_!=child.alias)) :: Nil | ||
| case o => o :: Nil | ||
| }, | ||
| child) | ||
| } | ||
| case Subquery(_, child) => child | ||
| } | ||
| } | ||
|
|
||
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.
Any particular reason for switching to transformDown?
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.
Thank you for your comments! If we doing transformUp, subquery will be removed at first. Then, Project(projectList, child: Subquery) will not be applicable in this case.