Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
JkSelf committed Oct 16, 2023
1 parent 8efe616 commit db3a09d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ abstract class FilterExecTransformerBase(val cond: Expression, val input: SparkP
extends UnaryExecNode
with TransformSupport
with PredicateHelper
with AliasAwareOutputExpression
with AliasAwareOutputPartitioning
with Logging {

// Note: "metrics" is made transient to avoid sending driver-side metrics to tasks.
Expand Down Expand Up @@ -220,7 +220,7 @@ case class ProjectExecTransformer private (projectList: Seq[NamedExpression], ch
extends UnaryExecNode
with TransformSupport
with PredicateHelper
with AliasAwareOutputExpression
with AliasAwareOutputPartitioning
with Logging {

// Note: "metrics" is made transient to avoid sending driver-side metrics to tasks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,10 @@
*/
package org.apache.spark.sql.execution

import org.apache.spark.sql.catalyst.expressions.{Alias, AttributeMap, AttributeReference, Expression, NamedExpression}
import org.apache.spark.sql.catalyst.plans.AliasAwareOutputExpression

/** A trait that provides functionality to handle aliases in the `outputExpressions`. */
trait AliasAwareOutputExpression extends UnaryExecNode {
protected def outputExpressions: Seq[NamedExpression]

private lazy val aliasMap = AttributeMap(outputExpressions.collect {
case a @ Alias(child: AttributeReference, _) => (child, a.toAttribute)
})

protected def hasAlias: Boolean = aliasMap.nonEmpty

protected def normalizeExpression(exp: Expression): Expression = {
exp.transform { case attr: AttributeReference => aliasMap.getOrElse(attr, attr) }
}
}
/**
* A trait that handles aliases in the `outputExpressions` to produce `outputPartitioning` that
* satisfies distribution requirements.
*/
trait AliasAwareOutputPartitioning extends AliasAwareOutputExpression {}

0 comments on commit db3a09d

Please sign in to comment.