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

    https://github.com/apache/spark/pull/18023#discussion_r119194989
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/parser/AstBuilder.scala
 ---
    @@ -1230,25 +1230,37 @@ class AstBuilder(conf: SQLConf) extends 
SqlBaseBaseVisitor[AnyRef] with Logging
       }
     
       /**
    -   * Create a dereference expression. The return type depends on the type 
of the parent, this can
    -   * either be a [[UnresolvedAttribute]] (if the parent is an 
[[UnresolvedAttribute]]), or an
    -   * [[UnresolvedExtractValue]] if the parent is some expression.
    +   * Create a dereference expression. The return type depends on the type 
of the parent.
    +   * If the parent is an [[UnresolvedAttribute]], it can be a 
[[UnresolvedAttribute]] or
    +   * a [[UnresolvedRegex]] for regex quoted in ``; if the parent is some 
other expression,
    +   * it can be [[UnresolvedExtractValue]].
        */
       override def visitDereference(ctx: DereferenceContext): Expression = 
withOrigin(ctx) {
         val attr = ctx.fieldName.getText
         expression(ctx.base) match {
    -      case UnresolvedAttribute(nameParts) =>
    -        UnresolvedAttribute(nameParts :+ attr)
    +      case unresolved_attr @ UnresolvedAttribute(nameParts) =>
    +        ctx.fieldName.getStart.getText match {
    +          case escapedIdentifier(columnNameRegex) if 
conf.supportQuotedRegexColumnName =>
    +            UnresolvedRegex(columnNameRegex, Some(unresolved_attr.name))
    +          case _ =>
    +            UnresolvedAttribute(nameParts :+ attr)
    +        }
           case e =>
             UnresolvedExtractValue(e, Literal(attr))
         }
       }
     
       /**
    -   * Create an [[UnresolvedAttribute]] expression.
    +   * Create an [[UnresolvedAttribute]] expression or a [[UnresolvedRegex]] 
if it is a regex
    --- End diff --
    
    @cloud-fan, the code path is shared by by both select a, select a.b and 
where cause. If it is select a.b, the table part also go here and it will not 
be right. I rolled back to the code before last friday (June 23rd, 2017).
    
    Do you have any suggestion? Currently Hive only supports select column 
regex expansion. and this PR matches the hive behavior.s
    



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to