dtenedor commented on code in PR #60736:
URL: https://github.com/apache/spark/pull/60736#discussion_r4646543968


##########
sql/connect/common/src/main/scala/org/apache/spark/sql/connect/client/GrpcExceptionConverter.scala:
##########
@@ -291,13 +291,26 @@ private[client] object GrpcExceptionConverter {
         getErrorClassOrFallback(params),
         errorParamsToMessageParameters(params),
         getSqlStateOrFallback(params))),
-    errorConstructor(params =>
-      new ParseException(
-        None,
-        Origin(),
-        errorClass = getErrorClassOrFallback(params),
-        messageParameters = errorParamsToMessageParameters(params),
-        queryContext = params.queryContext)),
+    errorConstructor { params =>

Review Comment:
   Done in 4c681e9b963. The check is now one helper, 
`renderOrKeepServerMessage`, and every `errorFactory` entry that renders from 
the client's definitions goes through it: `ParseException`, 
`AnalysisException`, the six catalog exceptions and the eight Spark exception 
types. Each class has a non-public `withRenderedMessage` factory, and the 
catalog exceptions' private constructors now take the SQLSTATE. 
`AnalysisException` uses its existing constructor that takes a message as is, 
and no public constructor changed. Following the decision question, the trigger 
is "the client cannot render the error": the condition is missing, or its 
template uses a parameter the server did not send.
   
   The new tests run each case against every entry. Without the converter 
change they fail with the `INTERNAL_ERROR`. I retitled the PR and updated the 
description.
   



##########
sql/connect/client/jvm/src/test/scala/org/apache/spark/sql/connect/client/SparkConnectClientSuite.scala:
##########
@@ -393,6 +394,72 @@ class SparkConnectClientSuite extends ConnectFunSuite {
     }
   }
 
+  test("ParseException keeps the server message for a condition the client 
does not define") {
+    val sqlContext = new QueryContext {
+      override def contextType(): QueryContextType = QueryContextType.SQL
+      override def objectType(): String = ""
+      override def objectName(): String = ""
+      override def startIndex(): Int = 0
+      override def stopIndex(): Int = 5
+      override def fragment(): String = "SELECT"
+      override def callSite(): String = ""
+      override def summary(): String = "== SQL (line 1, position 1) 
==\nSELECT\n^^^^^^\n"
+    }
+    Seq(
+      // A subcondition the client lacks, with a query context and the 
server's SQLSTATE.
+      (
+        "INVALID_SQL_SYNTAX.SUBCONDITION_NOT_DEFINED_BY_CLIENT",
+        Map("statement" -> "SELECT"),
+        Array(sqlContext),
+        Some("42000"),

Review Comment:
   Fixed in 4c681e9b963. The cases now include a server SQLSTATE (42601) that 
differs from the 42000 the client would derive, an undefined subcondition 
without a server SQLSTATE (expects 42000 from the main condition), and an 
undefined main condition without one (XXKCM). Both substitutions you describe 
now fail the test.
   



-- 
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