spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marmbrus <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-9778][SQL] remove unnecessary evaluatio...
Date Mon, 10 Aug 2015 23:21:16 GMT
Github user marmbrus commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8066#discussion_r36696583
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
    @@ -813,3 +815,66 @@ object RemoveLiteralFromGroupExpressions extends Rule[LogicalPlan]
{
           a.copy(groupingExpressions = newGrouping)
       }
     }
    +
    +/**
    + * Remove the unnecessary evaluation from SortOrder, if they are already in child's output.
    + *
    + * As an example, "select a + 1, b from t order by a + 1" will be analyzed into:
    + * {{{
    + *   Project(reference#2, b#0,
    + *     Sort('a#1 + 1,
    + *       Project(('a + 1)#2, b#0, a#1),
    + *         Relation)
    + * }}}
    + * Then this rule can optimize it into:
    + * {{{
    + *   Project(reference#2, b#0,
    + *     Sort(reference#2,
    + *       Project(('a + 1)#2, b#0, a#1),
    + *         Relation)
    + * }}}
    + * Finally other optimize rules(column pruning, project collapse) can turn it into:
    + * {{{
    + *   Sort(reference#2,
    + *     Project(('a + 1)#2, b#0),
    + *       Relation)
    + * }}}
    + */
    +object RemoveUnnecessarySortOrderEvaluation extends Rule[LogicalPlan] {
    +  private def trimAliases(e: Expression) = e.transformUp {
    +    case Alias(child, _) => child
    +  }
    +
    +  private def removeEvaluation(ordering: Seq[SortOrder], exprs: Seq[NamedExpression])
= {
    +    val OrderingExprs = ordering.map(_.child).map(trimAliases)
    --- End diff --
    
    Lowercase: `O`


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