Skip to content

Commit 75109a0

Browse files
committed
Only skip PlanExpression on executor.
1 parent 3a3bde0 commit 75109a0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package org.apache.spark.sql.catalyst.expressions
1919

2020
import scala.collection.mutable
2121

22+
import org.apache.spark.TaskContext
2223
import org.apache.spark.sql.catalyst.expressions.codegen.CodegenFallback
2324
import org.apache.spark.sql.catalyst.expressions.objects.LambdaVariable
2425

@@ -74,8 +75,8 @@ class EquivalentExpressions {
7475
// loop. So we can't evaluate sub-expressions containing `LambdaVariable` at the beginning.
7576
expr.find(_.isInstanceOf[LambdaVariable]).isDefined ||
7677
// `PlanExpression` wraps query plan. To compare query plans of `PlanExpression` on executor,
77-
// can cause unexpected error.
78-
expr.isInstanceOf[PlanExpression[_]]
78+
// can cause error like NPE.
79+
(expr.isInstanceOf[PlanExpression[_]] && TaskContext.get != null)
7980

8081
// There are some special expressions that we should not recurse into all of its children.
8182
// 1. CodegenFallback: it's children will not be used to generate code (call eval() instead)

0 commit comments

Comments
 (0)