spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From liancheng <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-12718][SPARK-13720][SQL] SQL generation...
Date Mon, 07 Mar 2016 15:08:14 GMT
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


Mime
View raw message