Skip to content

Conversation

@maropu
Copy link
Member

@maropu maropu commented Jun 2, 2017

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 PlanParserSuite and SQLQueryTestSuite.

@SparkQA
Copy link

SparkQA commented Jun 2, 2017

Test build #77671 has started for PR 18185 at commit 7d9d4ca.

@maropu
Copy link
Member Author

maropu commented Jun 2, 2017

Jenkins, retest this please.

@SparkQA
Copy link

SparkQA commented Jun 2, 2017

Test build #77672 has finished for PR 18185 at commit 7d9d4ca.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class UnresolvedRelation(tableIdentifier: TableIdentifier) extends LeafNode

@SparkQA
Copy link

SparkQA commented Jul 11, 2017

Test build #79519 has finished for PR 18185 at commit cd5d0ef.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@maropu
Copy link
Member Author

maropu commented Jul 11, 2017

@gatorsmile If you get time, could you check this? Thanks!

@maropu
Copy link
Member Author

maropu commented Jul 20, 2017

ping

@gatorsmile
Copy link
Member

Will review it tonight. Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a DDL syntax example here. Could you add it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Member

@gatorsmile gatorsmile Jul 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I'll check if we could do so.

@SparkQA
Copy link

SparkQA commented Jul 24, 2017

Test build #79901 has finished for PR 18185 at commit 5b272e4.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class UnresolvedSubqueryColumnAlias(

@maropu
Copy link
Member Author

maropu commented Jul 24, 2017

@gatorsmile ok, done. Could you check again?

@maropu
Copy link
Member Author

maropu commented Jul 27, 2017

ping

}
val subquery = SubqueryAlias(alias, plan(ctx.queryNoWith).optionalMap(ctx.sample)(withSample))
if (ctx.tableAlias.identifierList != null) {
val columnNames = visitIdentifierList(ctx.tableAlias.identifierList)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: columnNames -> columnAliases

*
* @param outputColumnNames the column names for this subquery.
* @param child the logical plan of this subquery.
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: UnresolvedSubqueryColumnAlias -> UnresolvedSubqueryColumnAliases

* SELECT col1, col2 FROM testData AS t(col1, col2);
* }}}
*
* @param outputColumnNames the column names for this subquery.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the logical plan of this subquery -> the [[LogicalPlan]] on which this subquery column aliases apply

override lazy val resolved = false
}

/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved by positions.

// 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. " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: remove the string Interpolator s.

@gatorsmile
Copy link
Member

LGTM except a few minor comments. Thanks for working on it!

@maropu
Copy link
Member Author

maropu commented Jul 27, 2017

Thanks! Fixed.

@SparkQA
Copy link

SparkQA commented Jul 28, 2017

Test build #80010 has finished for PR 18185 at commit 2b50e50.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class UnresolvedSubqueryColumnAliases(

@SparkQA
Copy link

SparkQA commented Jul 28, 2017

Test build #80011 has finished for PR 18185 at commit 23ca897.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • case class UnresolvedSubqueryColumnAliases(

@maropu
Copy link
Member Author

maropu commented Jul 28, 2017

@gatorsmile ok

// rule: ResolveDeserializer.
case plan if containsDeserializer(plan.expressions) => plan

case u @ UnresolvedSubqueryColumnAliases(columnNames, child) if child.resolved =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last question. What is the reason why we do not have a separate analyzer rule?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, I forgot to move this rule outside. I'll update soon.

@SparkQA
Copy link

SparkQA commented Jul 29, 2017

Test build #80031 has finished for PR 18185 at commit 277d6ee.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@gatorsmile
Copy link
Member

LGTM.

Thanks! Merging to master.

@asfgit asfgit closed this in 6550086 Jul 29, 2017
asfgit pushed a commit that referenced this pull request Aug 6, 2017
… 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 <[email protected]>

Closes #18857 from maropu/SPARK-20963-FOLLOWUP.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants