This is an automated email from the ASF dual-hosted git repository.

dongjoon 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 d356b17f1dca [SPARK-50380][SQL][TESTS][FOLLOWUP] Enable ANSI for 
conditional branches with error expression test
d356b17f1dca is described below

commit d356b17f1dcab83fd7eecc93b79e37608f4bb540
Author: Dongjoon Hyun <[email protected]>
AuthorDate: Sat Nov 23 18:35:50 2024 -0800

    [SPARK-50380][SQL][TESTS][FOLLOWUP] Enable ANSI for conditional branches 
with error expression test
    
    ### What changes were proposed in this pull request?
    
    This is a follow-up to recover non-ANSI CI.
    - #48918
    
    ### Why are the changes needed?
    
    The original PR broke non-ANSI CI because the test case assumes ANSI 
setting.
    
    - https://github.com/apache/spark/actions/runs/11964792566
    - https://github.com/apache/spark/actions/runs/11982859814
    
    ### Does this PR introduce _any_ user-facing change?
    
    No, this is a test-only change.
    
    ### How was this patch tested?
    
    Manual tests.
    
    **BEFORE**
    
    ```
    $ SPARK_ANSI_SQL_MODE=false build/sbt "catalyst/testOnly 
*.ReorderAssociativeOperatorSuite -- -z SPARK-50380"
    ...
    [info] *** 1 TEST FAILED ***
    [error] Failed tests:
    [error]         
org.apache.spark.sql.catalyst.optimizer.ReorderAssociativeOperatorSuite
    [error] (catalyst / Test / testOnly) sbt.TestsFailedException: Tests 
unsuccessful
    [error] Total time: 8 s, completed Nov 23, 2024, 11:50:45 AM
    ```
    
    **AFTER**
    
    ```
    $ SPARK_ANSI_SQL_MODE=false build/sbt "catalyst/testOnly 
*.ReorderAssociativeOperatorSuite -- -z SPARK-50380"
    ...
    [info] ReorderAssociativeOperatorSuite:
    [info] - SPARK-50380: conditional branches with error expression (508 
milliseconds)
    [info] Run completed in 1 second, 413 milliseconds.
    [info] Total number of tests run: 1
    [info] Suites: completed 1, aborted 0
    [info] Tests: succeeded 1, failed 0, canceled 0, ignored 0, pending 0
    [info] All tests passed.
    [success] Total time: 11 s, completed Nov 23, 2024, 11:51:34 AM
    ```
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #48943 from dongjoon-hyun/SPARK-50380.
    
    Authored-by: Dongjoon Hyun <[email protected]>
    Signed-off-by: Dongjoon Hyun <[email protected]>
---
 .../ReorderAssociativeOperatorSuite.scala          | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReorderAssociativeOperatorSuite.scala
 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReorderAssociativeOperatorSuite.scala
index 7733e58547fe..69c303d4773b 100644
--- 
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReorderAssociativeOperatorSuite.scala
+++ 
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/ReorderAssociativeOperatorSuite.scala
@@ -24,6 +24,7 @@ import 
org.apache.spark.sql.catalyst.expressions.aggregate.Count
 import org.apache.spark.sql.catalyst.plans.{Inner, PlanTest}
 import org.apache.spark.sql.catalyst.plans.logical.{LocalRelation, LogicalPlan}
 import org.apache.spark.sql.catalyst.rules.RuleExecutor
+import org.apache.spark.sql.internal.SQLConf
 
 class ReorderAssociativeOperatorSuite extends PlanTest {
 
@@ -109,15 +110,17 @@ class ReorderAssociativeOperatorSuite extends PlanTest {
   }
 
   test("SPARK-50380: conditional branches with error expression") {
-    val originalQuery1 = testRelation.select(If($"a" === 1, 1L, 
Literal(1).div(0) + $"b")).analyze
-    val optimized1 = Optimize.execute(originalQuery1)
-    comparePlans(optimized1, originalQuery1)
-
-    val originalQuery2 = testRelation.select(
-      If($"a" === 1, 1, ($"b" + Literal(Int.MaxValue)) + 1).as("col")).analyze
-    val optimized2 = Optimize.execute(originalQuery2)
-    val correctAnswer2 = testRelation.select(
-      If($"a" === 1, 1, $"b" + (Literal(Int.MaxValue) + 1)).as("col")).analyze
-    comparePlans(optimized2, correctAnswer2)
+    withSQLConf(SQLConf.ANSI_ENABLED.key -> true.toString) {
+      val originalQuery1 = testRelation.select(If($"a" === 1, 1L, 
Literal(1).div(0) + $"b")).analyze
+      val optimized1 = Optimize.execute(originalQuery1)
+      comparePlans(optimized1, originalQuery1)
+
+      val originalQuery2 = testRelation.select(
+        If($"a" === 1, 1, ($"b" + Literal(Int.MaxValue)) + 
1).as("col")).analyze
+      val optimized2 = Optimize.execute(originalQuery2)
+      val correctAnswer2 = testRelation.select(
+        If($"a" === 1, 1, $"b" + (Literal(Int.MaxValue) + 
1)).as("col")).analyze
+      comparePlans(optimized2, correctAnswer2)
+    }
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to