Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11555#discussion_r55227980
  
    --- 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 --
    
    This is really a good idea! thanks, updated.


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