This is an automated email from the ASF dual-hosted git repository. gengliang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/master by this push: new 788e157ab55 [SPARK-40016][SQL] Remove unnecessary TryEval in the implementation of try_sum() 788e157ab55 is described below commit 788e157ab5595baed8c6a8ba898ae4018c9e7d57 Author: Gengliang Wang <gengli...@apache.org> AuthorDate: Tue Aug 9 22:35:24 2022 -0700 [SPARK-40016][SQL] Remove unnecessary TryEval in the implementation of try_sum() ### What changes were proposed in this pull request? Remove unnecessary TryEval in the implementation of try_sum() ### Why are the changes needed? For simplicity. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Existing unit test Closes #37446 from gengliangwang/updateTrySum. Authored-by: Gengliang Wang <gengli...@apache.org> Signed-off-by: Gengliang Wang <gengli...@apache.org> --- .../spark/sql/catalyst/expressions/aggregate/Sum.scala | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala index e8492c0e5dc..869a27c6161 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/aggregate/Sum.scala @@ -249,17 +249,15 @@ case class TrySum(child: Expression) extends SumBase(child) { override lazy val mergeExpressions: Seq[Expression] = if (useAnsiAdd) { - getMergeExpressions.map(TryEval) + val expressions = getMergeExpressions + // If the length of getMergeExpressions is larger than 1, the tail expressions are for + // tracking whether the input is empty, which doesn't need `TryEval` execution. + Seq(TryEval(expressions.head)) ++ expressions.tail } else { getMergeExpressions } - override lazy val evaluateExpression: Expression = - if (useAnsiAdd) { - TryEval(getEvaluateExpression()) - } else { - getEvaluateExpression() - } + override lazy val evaluateExpression: Expression = getEvaluateExpression() override protected def withNewChildInternal(newChild: Expression): Expression = copy(child = newChild) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org