Skip to content

Commit

Permalink
[SPARK-30620][SQL] avoid unnecessary serialization in AggregateExpres…
Browse files Browse the repository at this point in the history
…sion

### What changes were proposed in this pull request?

Expressions are very likely to be serialized and sent to executors, we should avoid unnecessary serialization overhead as much as we can.

This PR fixes `AggregateExpression`.

### Why are the changes needed?

small improvement

### Does this PR introduce any user-facing change?

no

### How was this patch tested?

existing tests

Closes #27342 from cloud-fan/fix.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
  • Loading branch information
cloud-fan committed Jan 23, 2020
1 parent 3d7359a commit 3c8b360
Showing 1 changed file with 2 additions and 1 deletion.
Expand Up @@ -96,6 +96,7 @@ case class AggregateExpression(
extends Expression
with Unevaluable {

@transient
lazy val resultAttribute: Attribute = if (aggregateFunction.resolved) {
AttributeReference(
aggregateFunction.toString,
Expand All @@ -108,7 +109,7 @@ case class AggregateExpression(
UnresolvedAttribute(aggregateFunction.toString)
}

lazy val filterAttributes: AttributeSet = filter.map(_.references).getOrElse(AttributeSet.empty)
def filterAttributes: AttributeSet = filter.map(_.references).getOrElse(AttributeSet.empty)

// We compute the same thing regardless of our final result.
override lazy val canonicalized: Expression = {
Expand Down

0 comments on commit 3c8b360

Please sign in to comment.