[SPARK-20962][SQL] Support subquery column aliases in FROM clause#18185
[SPARK-20962][SQL] Support subquery column aliases in FROM clause#18185maropu wants to merge 5 commits intoapache:masterfrom
Conversation
|
Test build #77671 has started for PR 18185 at commit |
|
Jenkins, retest this please. |
|
Test build #77672 has finished for PR 18185 at commit
|
|
Test build #79519 has finished for PR 18185 at commit
|
|
@gatorsmile If you get time, could you check this? Thanks! |
|
ping |
|
Will review it tonight. Thanks! |
There was a problem hiding this comment.
We need a DDL syntax example here. Could you add it?
There was a problem hiding this comment.
The impact of changing SubqueryAlias is too big. How about adding a new operator node UnresolvedColumnAlias? In the analyzer, UnresolvedColumnAlias will be replaced by a Project? The resolution is by position.
There was a problem hiding this comment.
ok, I'll check if we could do so.
|
Test build #79901 has finished for PR 18185 at commit
|
|
@gatorsmile ok, done. Could you check again? |
|
ping |
| } | ||
| val subquery = SubqueryAlias(alias, plan(ctx.queryNoWith).optionalMap(ctx.sample)(withSample)) | ||
| if (ctx.tableAlias.identifierList != null) { | ||
| val columnNames = visitIdentifierList(ctx.tableAlias.identifierList) |
There was a problem hiding this comment.
Nit: columnNames -> columnAliases
| * | ||
| * @param outputColumnNames the column names for this subquery. | ||
| * @param child the logical plan of this subquery. | ||
| */ |
There was a problem hiding this comment.
Nit: UnresolvedSubqueryColumnAlias -> UnresolvedSubqueryColumnAliases
| * SELECT col1, col2 FROM testData AS t(col1, col2); | ||
| * }}} | ||
| * | ||
| * @param outputColumnNames the column names for this subquery. |
There was a problem hiding this comment.
Nit: the logical plan of this subquery -> the [[LogicalPlan]] on which this subquery column aliases apply
| override lazy val resolved = false | ||
| } | ||
|
|
||
| /** |
| // Checks if the number of the aliases equals to the number of output columns | ||
| // in the subquery. | ||
| if (columnNames.size != outputAttrs.size) { | ||
| u.failAnalysis(s"Number of column aliases does not match number of columns. " + |
There was a problem hiding this comment.
Nit: remove the string Interpolator s.
|
LGTM except a few minor comments. Thanks for working on it! |
|
Thanks! Fixed. |
|
Test build #80010 has finished for PR 18185 at commit
|
|
Test build #80011 has finished for PR 18185 at commit
|
|
@gatorsmile ok |
| // rule: ResolveDeserializer. | ||
| case plan if containsDeserializer(plan.expressions) => plan | ||
|
|
||
| case u @ UnresolvedSubqueryColumnAliases(columnNames, child) if child.resolved => |
There was a problem hiding this comment.
The last question. What is the reason why we do not have a separate analyzer rule?
There was a problem hiding this comment.
Yea, I forgot to move this rule outside. I'll update soon.
|
Test build #80031 has finished for PR 18185 at commit
|
|
LGTM. Thanks! Merging to master. |
… visitTableName ## What changes were proposed in this pull request? This pr (follow-up of #18772) used `UnresolvedSubqueryColumnAliases` for `visitTableName` in `AstBuilder`, which is a new unresolved `LogicalPlan` implemented in #18185. ## How was this patch tested? Existing tests Author: Takeshi Yamamuro <yamamuro@apache.org> Closes #18857 from maropu/SPARK-20963-FOLLOWUP.
What changes were proposed in this pull request?
This pr added parsing rules to support subquery column aliases in FROM clause.
This pr is a sub-task of #18079.
How was this patch tested?
Added tests in
PlanParserSuiteandSQLQueryTestSuite.