gatorsmile commented on code in PR #40672:
URL: https://github.com/apache/spark/pull/40672#discussion_r1159258510


##########
python/pyspark/sql/tests/connect/test_connect_basic.py:
##########
@@ -229,8 +230,29 @@ def test_df_get_item(self):
     def test_error_handling(self):
         # SPARK-41533 Proper error handling for Spark Connect
         df = self.connect.range(10).select("id2")
-        with self.assertRaises(AnalysisException):
+        with self.assertRaises(AnalysisException) as e:
             df.collect()
+        self.check_error(
+            exception=e.exception,
+            error_class="UNRESOLVED_COLUMN.WITH_SUGGESTION",
+            message_parameters=dict(objectName="`id2`", proposal="`id`")
+        )
+
+    def test_error_classes(self):
+        with self.assertRaises(ParseException) as e:
+            self.connect.sql("select ;")
+        self.assertEqual(e.exception.getErrorClass(), "PARSE_SYNTAX_ERROR")
+
+        self.connect.conf.set("spark.sql.ansi.enabled", True)
+        with self.assertRaises(ArithmeticException) as e:
+            self.connect.sql("select 1/0").collect()
+        self.assertEqual(e.exception.getErrorClass(), "DIVIDE_BY_ZERO")
+        self.connect.conf.set("spark.sql.ansi.enabled", False)
+
+        with self.assertRaises(SparkConnectException) as e:
+            df = self.connect.createDataFrame({'x': 1, 'y': 2})
+            df.write.mode("overwrite").format("noformat").saveAsTable("t")
+        self.assertEqual(e.exception.getErrorClass(), "DATA_SOURCE_NOT_FOUND")

Review Comment:
   This only covers Spark Connect mode. How about the cases when Spark Connect 
is off?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to