MaxGekk commented on code in PR #38364:
URL: https://github.com/apache/spark/pull/38364#discussion_r1002902138


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/parser/TableIdentifierParserSuite.scala:
##########
@@ -290,9 +290,35 @@ class TableIdentifierParserSuite extends SQLKeywordUtils {
     assert(TableIdentifier("q", Option("d")) === parseTableIdentifier("d.q"))
 
     // Illegal names.
-    Seq("", "d.q.g", "t:", "${some.var.x}", "tab:1").foreach { identifier =>
-      intercept[ParseException](parseTableIdentifier(identifier))
-    }
+    val identifier1 = ""
+    checkError(
+      exception = intercept[ParseException](parseTableIdentifier(identifier1)),
+      errorClass = "PARSE_EMPTY_STATEMENT",
+      parameters = Map.empty)
+
+    val identifier2 = "d.q.g"
+    checkError(
+      exception = intercept[ParseException](parseTableIdentifier(identifier2)),
+      errorClass = "PARSE_SYNTAX_ERROR",
+      parameters = Map("error" -> "'.'", "hint" -> ""))
+
+    val identifier3 = "t:"
+    checkError(
+      exception = intercept[ParseException](parseTableIdentifier(identifier3)),
+      errorClass = "PARSE_SYNTAX_ERROR",
+      parameters = Map("error" -> "':'", "hint" -> ": extra input ':'"))
+
+    val identifier4 = "${some.var.x}"
+    checkError(
+      exception = intercept[ParseException](parseTableIdentifier(identifier4)),
+      errorClass = "PARSE_SYNTAX_ERROR",
+      parameters = Map("error" -> "'$'", "hint" -> ""))
+
+    val identifier5 = "tab:1"
+    checkError(
+      exception = intercept[ParseException](parseTableIdentifier(identifier5)),
+      errorClass = "PARSE_SYNTAX_ERROR",
+      parameters = Map("error" -> "':'", "hint" -> ""))

Review Comment:
   Could you avoid boilerplate code like
   ```suggestion
       Seq(
         "" -> Map.empty[String, String],
         "d.q.g" -> Map("error" -> "'.'", "hint" -> ""),
         "t:" -> Map("error" -> "':'", "hint" -> ": extra input ':'"),
         "${some.var.x}" -> Map("error" -> "'$'", "hint" -> ""),
         "tab:1" -> Map("error" -> "':'", "hint" -> "")
       ).foreach { case (identifier, parameters) =>
         checkError(
           exception = 
intercept[ParseException](parseTableIdentifier(identifier)),
           errorClass = "PARSE_EMPTY_STATEMENT",
           parameters = parameters)
       }
   ```



-- 
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-unsubscr...@spark.apache.org

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


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

Reply via email to