This is an automated email from the ASF dual-hosted git repository. wenchen 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 a40acd4 [SPARK-38333][SQL] PlanExpression expression should skip addExprTree function in Executor a40acd4 is described below commit a40acd4392a8611062763ce6ec7bc853d401c646 Author: Dereck Li <monkeyboy....@gmail.com> AuthorDate: Thu Mar 31 21:33:08 2022 +0800 [SPARK-38333][SQL] PlanExpression expression should skip addExprTree function in Executor ### What changes were proposed in this pull request? It is master branch pr [SPARK-38333](https://github.com/apache/spark/pull/35662) ### Why are the changes needed? Bug fix, it is potential issue. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? UT Closes #36012 from monkeyboy123/spark-38333. Authored-by: Dereck Li <monkeyboy....@gmail.com> Signed-off-by: Wenchen Fan <wenc...@databricks.com> --- .../catalyst/expressions/EquivalentExpressions.scala | 2 +- .../expressions/SubexpressionEliminationSuite.scala | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala index 903a6fd..472b6e8 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala @@ -197,7 +197,7 @@ class EquivalentExpressions { expr.exists(_.isInstanceOf[LambdaVariable]) || // `PlanExpression` wraps query plan. To compare query plans of `PlanExpression` on executor, // can cause error like NPE. - (expr.isInstanceOf[PlanExpression[_]] && Utils.isInRunningSparkTask) + (expr.exists(_.isInstanceOf[PlanExpression[_]]) && Utils.isInRunningSparkTask) if (!skip && !updateExprInMap(expr, map, useCount)) { val uc = useCount.signum diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala index fa3003b..3c96ba4 100644 --- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala +++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/SubexpressionEliminationSuite.scala @@ -16,8 +16,9 @@ */ package org.apache.spark.sql.catalyst.expressions -import org.apache.spark.SparkFunSuite +import org.apache.spark.{SparkFunSuite, TaskContext, TaskContextImpl} import org.apache.spark.sql.catalyst.expressions.codegen._ +import org.apache.spark.sql.catalyst.plans.logical.LocalRelation import org.apache.spark.sql.internal.SQLConf import org.apache.spark.sql.types.{BinaryType, DataType, Decimal, IntegerType} @@ -419,6 +420,21 @@ class SubexpressionEliminationSuite extends SparkFunSuite with ExpressionEvalHel } } + test("SPARK-38333: PlanExpression expression should skip addExprTree function in Executor") { + try { + // suppose we are in executor + val context1 = new TaskContextImpl(0, 0, 0, 0, 0, null, null, null, cpus = 0) + TaskContext.setTaskContext(context1) + + val equivalence = new EquivalentExpressions + val expression = DynamicPruningExpression(Exists(LocalRelation())) + equivalence.addExprTree(expression) + assert(equivalence.getExprState(expression).isEmpty) + } finally { + TaskContext.unset() + } + } + test("SPARK-35886: PromotePrecision should not overwrite genCode") { val p = PromotePrecision(Literal(Decimal("10.1"))) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org