Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18185#discussion_r129943038
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ---
    @@ -750,20 +750,28 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
       /**
        * Create an alias (SubqueryAlias) for a sub-query. This is practically 
the same as
        * visitAliasedRelation and visitNamedExpression, ANTLR4 however 
requires us to use 3 different
    -   * hooks.
    +   * hooks. We could add alias names for output columns, for example:
    +   * {{{
    +   *   SELECT col1, col2 FROM testData AS t(col1, col2)
    +   * }}}
        */
       override def visitAliasedQuery(ctx: AliasedQueryContext): LogicalPlan = 
withOrigin(ctx) {
    -    val alias = if (ctx.strictIdentifier == null) {
    +    val alias = if (ctx.tableAlias.strictIdentifier == null) {
           // For un-aliased subqueries, use a default alias name that is not 
likely to conflict with
           // normal subquery names, so that parent operators can only access 
the columns in subquery by
           // unqualified names. Users can still use this special qualifier to 
access columns if they
           // know it, but that's not recommended.
           "__auto_generated_subquery_name"
         } else {
    -      ctx.strictIdentifier.getText
    +      ctx.tableAlias.strictIdentifier.getText
    +    }
    +    val subquery = SubqueryAlias(alias, 
plan(ctx.queryNoWith).optionalMap(ctx.sample)(withSample))
    +    if (ctx.tableAlias.identifierList != null) {
    +      val columnNames = visitIdentifierList(ctx.tableAlias.identifierList)
    --- End diff --
    
    Nit: `columnNames ` -> `columnAliases`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to