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


##########
sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveExternalCatalog.scala:
##########
@@ -172,8 +172,13 @@ private[spark] class HiveExternalCatalog(conf: SparkConf, 
hadoopConf: Configurat
         f.dataType match {
           // Checks top-level column names
           case _ if f.name.contains(",") =>
-            throw new AnalysisException("Cannot create a table having a column 
whose name " +
-              s"contains commas in Hive metastore. Table: $tableName; Column: 
${f.name}")
+            throw new AnalysisException(
+              errorClass = "INVALID_HIVE_COLUMN_NAME",
+              messageParameters = Map(
+                "invalidChars" -> "','",

Review Comment:
   Could you form the char using `toSQLValue(',', ...`



##########
sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala:
##########
@@ -2143,9 +2143,10 @@ abstract class SQLQuerySuiteBase extends QueryTest with 
SQLTestUtils with TestHi
 
   test("Auto alias construction of get_json_object") {
     val df = Seq(("1", """{"f1": "value1", "f5": 5.23}""")).toDF("key", 
"jstring")
-    val expectedMsg = "Cannot create a table having a column whose name 
contains commas " +
-      s"in Hive metastore. Table: `$SESSION_CATALOG_NAME`.`default`.`t`; 
Column: " +
-      "get_json_object(jstring, $.f1)"
+    val expectedMsg = "[INVALID_HIVE_COLUMN_NAME] Cannot create the " +
+      s"table `$SESSION_CATALOG_NAME`.`default`.`t` having the " +
+      "column `get_json_object(jstring, $`.`f1)` " +
+      "whose name contains invalid characters ',' in Hive metastore."

Review Comment:
   Could you change the test and use `checkError` instead of checking error 
format. The error message can be changed by tech editors in the future or 
translated to other languages. It would be nice if the test won't depend on 
such changes.



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