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

wenchen 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 cc2ecef6f91a [SPARK-55320][SQL][CONNECT] Use raise_error instead of 
divide by zero in Observation tests
cc2ecef6f91a is described below

commit cc2ecef6f91a1fcca96637c3c4b84f11ab6a3e24
Author: Yihong He <[email protected]>
AuthorDate: Tue Feb 3 16:36:43 2026 +0800

    [SPARK-55320][SQL][CONNECT] Use raise_error instead of divide by zero in 
Observation tests
    
    ### What changes were proposed in this pull request?
    
    Use raise_error instead of divide by zero in Observation tests
    
    ### Why are the changes needed?
    
    The tests fail when ANSI mode is disabled.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    `SPARK_ANSI_SQL_MODE="false" build/sbt "sql/testOnly *DatasetSuite -- -z 
SPARK-55150"`
    `SPARK_ANSI_SQL_MODE="false" build/sbt "connect-client-jvm/testOnly 
*ClientE2ETestSuite -- -z SPARK-55150"`
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Yes
    
    Closes #54099 from heyihong/SPARK-55320.
    
    Authored-by: Yihong He <[email protected]>
    Signed-off-by: Wenchen Fan <[email protected]>
---
 .../test/scala/org/apache/spark/sql/connect/ClientE2ETestSuite.scala | 5 ++++-
 sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala      | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/ClientE2ETestSuite.scala
 
b/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/ClientE2ETestSuite.scala
index a352c67b8721..5ff030b56d4c 100644
--- 
a/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/ClientE2ETestSuite.scala
+++ 
b/sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/ClientE2ETestSuite.scala
@@ -1620,7 +1620,10 @@ class ClientE2ETestSuite
     val observation = Observation("test_observation")
     val observed_df = spark
       .range(10)
-      .observe(observation, sum("id").as("sum_id"), (sum("id") / 
lit(0)).as("sum_id_div_by_zero"))
+      .observe(
+        observation,
+        sum("id").as("sum_id"),
+        raise_error(lit("test error")).as("raise_error"))
 
     observed_df.collect()
 
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
index 1f9a30b1cc44..2aefd011851e 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala
@@ -1164,7 +1164,7 @@ class DatasetSuite extends QueryTest
     val observed_df = spark.range(10).observe(
       observation,
       sum($"id").as("sum_id"),
-      (sum($"id") / lit(0)).as("sum_id_div_by_zero")
+      raise_error(lit("test error")).as("raise_error")
     )
 
     observed_df.collect()
@@ -1173,7 +1173,7 @@ class DatasetSuite extends QueryTest
       observation.get
     }
 
-    assert(exception.getCause.getMessage.contains("DIVIDE_BY_ZERO"))
+    assert(exception.getCause.getMessage.contains("test error"))
   }
 
   test("sample with replacement") {


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

Reply via email to