You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/09/15 17:13:50 UTC

[GitHub] [spark] karenfeng commented on a change in pull request #33627: [SPARK-36405] Check that SQLSTATEs are valid

karenfeng commented on a change in pull request #33627:
URL: https://github.com/apache/spark/pull/33627#discussion_r709387628



##########
File path: core/src/test/scala/org/apache/spark/SparkThrowableSuite.scala
##########
@@ -73,7 +74,17 @@ class SparkThrowableSuite extends SparkFunSuite {
 
   test("SQLSTATE invariants") {
     val sqlStates = errorClassToInfoMap.values.toSeq.flatMap(_.sqlState)
-    checkCondition(sqlStates, s => s.length == 5)
+    val errorClassReadMe = Utils.getSparkClassLoader.getResource("error/README.md")
+    val errorClassReadMeContents = IOUtils.toString(errorClassReadMe.openStream())
+    val sqlStateTableRegex =
+      "(?s)\\[//]: # \\(SQLSTATE table start\\)(.+)\\[//]: # \\(SQLSTATE table end\\)".r
+    val sqlTable = sqlStateTableRegex.findFirstIn(errorClassReadMeContents).get
+    val sqlTableRows = sqlTable.split("\n").filter(_.startsWith("|")).drop(2)
+    val validSqlStates = sqlTableRows.map(_.slice(1, 6)).toSet
+    // Sanity check
+    assert(Set("07000", "42000", "HZ000").subsetOf(validSqlStates), validSqlStates)

Review comment:
       We validate the SQLSTATEs in the JSON below. This just checks that we extracted SQLSTATEs from the table.




-- 
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: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org