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

    https://github.com/apache/spark/pull/11555#discussion_r55215536
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/SQLBuilder.scala ---
    @@ -204,11 +207,70 @@ class SQLBuilder(logicalPlan: LogicalPlan, 
sqlContext: SQLContext) extends Loggi
       private def build(segments: String*): String =
         segments.map(_.trim).filter(_.nonEmpty).mkString(" ")
     
    +  /**
    +   * Given a seq of qualifiers(names and their corresponding 
[[AttributeSet]]), transform the given
    +   * expression tree, if an [[Attribute]] belongs to one of the 
[[AttributeSet]]s, update its
    +   * qualifier with the corresponding name of the [[AttributeSet]].
    +   */
    +  private def updateQualifier(
    +      expr: Expression,
    +      qualifiers: Seq[(String, AttributeSet)]): Expression = {
    +    if (qualifiers.isEmpty) {
    +      expr
    +    } else {
    +      expr transform {
    +        case a: Attribute =>
    +          val index = qualifiers.indexWhere {
    +            case (_, inputAttributes) => inputAttributes.contains(a)
    +          }
    +          if (index == -1) {
    +            a
    +          } else {
    +            a.withQualifiers(qualifiers(index)._1 :: Nil)
    +          }
    +      }
    +    }
    +  }
    +
    +  /**
    +   * Finds the outer most [[SubqueryAlias]] nodes in the input logical 
plan and return their alias
    +   * names and outputSet.
    +   */
    +  private def findOutermostQualifiers(input: LogicalPlan): Seq[(String, 
AttributeSet)] = {
    --- End diff --
    
    Thanks, I like this one :)


---
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