From 07359fa7b5cfc2bbab7ef870070955ccf542313f Mon Sep 17 00:00:00 2001 From: Peter Toth Date: Tue, 13 Dec 2022 09:13:00 +0100 Subject: [PATCH] [SPARK-41468][SQL][FOLLOWUP] Handle NamedLambdaVariables in EquivalentExpressions --- .../sql/catalyst/expressions/EquivalentExpressions.scala | 5 +++-- 1 file changed, 3 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 3ffd9f9d88750..330d66a21bea5 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 @@ -144,9 +144,10 @@ class EquivalentExpressions { private def supportedExpression(e: Expression) = { !e.exists { - // `LambdaVariable` is usually used as a loop variable, which can't be evaluated ahead of the - // loop. So we can't evaluate sub-expressions containing `LambdaVariable` at the beginning. + // `LambdaVariable` is usually used as a loop variable and `NamedLambdaVariable` is used in + // higher-order functions, which can't be evaluated ahead of the execution. case _: LambdaVariable => true + case _: NamedLambdaVariable => true // `PlanExpression` wraps query plan. To compare query plans of `PlanExpression` on executor, // can cause error like NPE.