You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by gu...@apache.org on 2020/02/24 07:48:31 UTC
[spark] branch branch-3.0 updated: [SPARK-30897][SQL] The behavior
of ArrayExists should not depend on SQLConf.get
This is an automated email from the ASF dual-hosted git repository.
gurwls223 pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 089ef4f [SPARK-30897][SQL] The behavior of ArrayExists should not depend on SQLConf.get
089ef4f is described below
commit 089ef4f91db30be2466a620f9c478a379163e5a2
Author: Peter Toth <pe...@gmail.com>
AuthorDate: Mon Feb 24 16:47:08 2020 +0900
[SPARK-30897][SQL] The behavior of ArrayExists should not depend on SQLConf.get
### What changes were proposed in this pull request?
This PR adds a new `followThreeValuedLogic` parameter to `ArrayExists` so as to avoid its value depending on `SQLConf.get` and change during planning.
### Why are the changes needed?
This allows to avoid the issue when the configuration change between different phases of planning, and this can silently break a query plan which can lead to crashes or data corruption.
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
Existing UTs.
Closes #27655 from peter-toth/SPARK-30897.
Authored-by: Peter Toth <pe...@gmail.com>
Signed-off-by: HyukjinKwon <gu...@apache.org>
(cherry picked from commit 612f63f39ef91a06b71d40e20ad0216cb88776a1)
Signed-off-by: HyukjinKwon <gu...@apache.org>
---
.../sql/catalyst/expressions/higherOrderFunctions.scala | 17 ++++++++++++++---
.../optimizer/ReplaceNullWithFalseInPredicate.scala | 3 +--
.../ReplaceNullWithFalseInPredicateSuite.scala | 2 +-
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
index f8142d6..9dd4263 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/higherOrderFunctions.scala
@@ -522,11 +522,16 @@ case class ArrayFilter(
since = "2.4.0")
case class ArrayExists(
argument: Expression,
- function: Expression)
+ function: Expression,
+ followThreeValuedLogic: Boolean)
extends ArrayBasedSimpleHigherOrderFunction with CodegenFallback {
- private val followThreeValuedLogic =
- SQLConf.get.getConf(SQLConf.LEGACY_ARRAY_EXISTS_FOLLOWS_THREE_VALUED_LOGIC)
+ def this(argument: Expression, function: Expression) = {
+ this(
+ argument,
+ function,
+ SQLConf.get.getConf(SQLConf.LEGACY_ARRAY_EXISTS_FOLLOWS_THREE_VALUED_LOGIC))
+ }
override def nullable: Boolean =
if (followThreeValuedLogic) {
@@ -574,6 +579,12 @@ case class ArrayExists(
override def prettyName: String = "exists"
}
+object ArrayExists {
+ def apply(argument: Expression, function: Expression): ArrayExists = {
+ new ArrayExists(argument, function)
+ }
+}
+
/**
* Tests whether a predicate holds for all elements in the array.
*/
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicate.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicate.scala
index b8edf98..33b398e 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicate.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicate.scala
@@ -64,8 +64,7 @@ object ReplaceNullWithFalseInPredicate extends Rule[LogicalPlan] {
case af @ ArrayFilter(_, lf @ LambdaFunction(func, _, _)) =>
val newLambda = lf.copy(function = replaceNullWithFalse(func))
af.copy(function = newLambda)
- case ae @ ArrayExists(_, lf @ LambdaFunction(func, _, _))
- if !SQLConf.get.getConf(SQLConf.LEGACY_ARRAY_EXISTS_FOLLOWS_THREE_VALUED_LOGIC) =>
+ case ae @ ArrayExists(_, lf @ LambdaFunction(func, _, _), false) =>
val newLambda = lf.copy(function = replaceNullWithFalse(func))
ae.copy(function = newLambda)
case mf @ MapFilter(_, lf @ LambdaFunction(func, _, _)) =>
diff --git a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicateSuite.scala b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicateSuite.scala
index b692c3f..c7f42f0 100644
--- a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicateSuite.scala
+++ b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReplaceNullWithFalseInPredicateSuite.scala
@@ -324,7 +324,7 @@ class ReplaceNullWithFalseInPredicateSuite extends PlanTest {
testProjection(originalExpr = expr, expectedExpr = expr)
}
withSQLConf(SQLConf.LEGACY_ARRAY_EXISTS_FOLLOWS_THREE_VALUED_LOGIC.key -> "false") {
- testHigherOrderFunc('a, ArrayExists, Seq(lv('e)))
+ testHigherOrderFunc('a, ArrayExists.apply, Seq(lv('e)))
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org