pan3793 commented on code in PR #58022:
URL: https://github.com/apache/spark/pull/58022#discussion_r3789519760


##########
sql/connect/client/jdbc/src/test/scala/org/apache/spark/sql/connect/client/jdbc/util/JdbcErrorUtilsSuite.scala:
##########
@@ -26,38 +26,47 @@ import org.apache.spark.sql.connect.test.ConnectFunSuite
 
 /**
  * Tests for [[JdbcErrorUtils.toSQLException]]. A RuntimeException mixing in
- * [[SparkThrowable]] stands in for converted server errors; a real
- * [[StatusRuntimeException]] cause models transport errors the way
- * GrpcExceptionConverter preserves them.
+ * [[SparkThrowable]] stands in for converted server errors, carrying the 
sqlState
+ * GrpcExceptionConverter would supply. A real [[StatusRuntimeException]] cause
+ * models transport errors the way GrpcExceptionConverter preserves them.
  */
 class JdbcErrorUtilsSuite extends ConnectFunSuite {
 
   private def sparkError(
       condition: String,
+      sqlState: String,
       msg: String,
       cause: Throwable = null): RuntimeException =
     new RuntimeException(msg, cause) with SparkThrowable {
       override def getCondition: String = condition
+      override def getSqlState: String = sqlState
     }
 
   private def grpcError(status: Status): StatusRuntimeException =
     new StatusRuntimeException(status)
 
-  test("INVALID_HANDLE.SESSION_CLOSED maps to a connection exception with 
SQLState 08003") {
+  test("a class-08 SQLSTATE maps to a non-transient connection exception") {
     val e = JdbcErrorUtils.toSQLException(
-      sparkError("INVALID_HANDLE.SESSION_CLOSED", "Session was closed"))
+      sparkError("INVALID_HANDLE.SESSION_CLOSED", "08003", "Session was 
closed"))
     assert(e.isInstanceOf[SQLNonTransientConnectionException])
     assert(e.getSQLState === "08003")
     assert(e.getMessage === "Session was closed")
   }
 
-  test("other session-level INVALID_HANDLE subconditions also map to 08003") {
-    Seq("INVALID_HANDLE.SESSION_NOT_FOUND", 
"INVALID_HANDLE.SESSION_CHANGED").foreach {
-      condition =>
-        val e = JdbcErrorUtils.toSQLException(sparkError(condition, "gone"))
-        assert(e.isInstanceOf[SQLNonTransientConnectionException], condition)
-        assert(e.getSQLState === "08003", condition)
-    }
+  test("the class-08 mapping does not depend on the condition name") {
+    val e = JdbcErrorUtils.toSQLException(sparkError("SOME_FUTURE_CONDITION", 
"08004", "gone"))
+    assert(e.isInstanceOf[SQLNonTransientConnectionException])
+    assert(e.getSQLState === "08004")
+  }
+
+  test("a session error from a pre-4.3 server keeps the server-provided 
HY000") {

Review Comment:
   We don't need this because Spark Connect requires the client version <= 
server version



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