Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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")))

Expand Down