uros-db commented on code in PR #47825:
URL: https://github.com/apache/spark/pull/47825#discussion_r1724994636


##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLExpressionsSuite.scala:
##########
@@ -996,6 +996,30 @@ class CollationSQLExpressionsSuite
         assert(sql(query).schema.fields.head.dataType.sameType(dataType))
       }
     })
+
+    val tableName = "t_diff_collation"
+    withTable(tableName) {
+      sql(s"CREATE TABLE $tableName (" +
+        s"text STRING COLLATE UTF8_BINARY, " +
+        s"pairDelim STRING COLLATE UTF8_LCASE, " +
+        s"keyValueDelim STRING COLLATE UTF8_BINARY) " +
+        s"USING parquet")
+      checkError(
+        exception = intercept[AnalysisException] {
+          sql(s"SELECT str_to_map(text, pairDelim, keyValueDelim) from 
$tableName")
+        },
+        errorClass = "DATATYPE_MISMATCH.DATA_DIFF_TYPES",
+        sqlState = "42K09",
+        parameters = Map(
+          "functionName" -> "`str_to_map`",
+          "dataType" -> "[\"STRING\", \"STRING COLLATE UTF8_LCASE\", 
\"STRING\"]",
+          "sqlExpr" -> "\"str_to_map(text, pairDelim, keyValueDelim)\""),
+        context = ExpectedContext(
+          fragment = "str_to_map(text, pairDelim, keyValueDelim)",
+          start = 7,
+          stop = 48)
+      )
+    }

Review Comment:
   we shouldn't use `DATATYPE_MISMATCH.DATA_DIFF_TYPES` for collation matching
   
   please see `COLLATION_MISMATCH.EXPLICIT`, there should be many tests across 
the codebase market with "// Collation mismatch"



##########
sql/core/src/test/scala/org/apache/spark/sql/CollationSQLExpressionsSuite.scala:
##########
@@ -996,6 +996,30 @@ class CollationSQLExpressionsSuite
         assert(sql(query).schema.fields.head.dataType.sameType(dataType))
       }
     })
+
+    val tableName = "t_diff_collation"
+    withTable(tableName) {
+      sql(s"CREATE TABLE $tableName (" +
+        s"text STRING COLLATE UTF8_BINARY, " +
+        s"pairDelim STRING COLLATE UTF8_LCASE, " +
+        s"keyValueDelim STRING COLLATE UTF8_BINARY) " +
+        s"USING parquet")
+      checkError(
+        exception = intercept[AnalysisException] {
+          sql(s"SELECT str_to_map(text, pairDelim, keyValueDelim) from 
$tableName")
+        },
+        errorClass = "DATATYPE_MISMATCH.DATA_DIFF_TYPES",
+        sqlState = "42K09",
+        parameters = Map(
+          "functionName" -> "`str_to_map`",
+          "dataType" -> "[\"STRING\", \"STRING COLLATE UTF8_LCASE\", 
\"STRING\"]",
+          "sqlExpr" -> "\"str_to_map(text, pairDelim, keyValueDelim)\""),
+        context = ExpectedContext(
+          fragment = "str_to_map(text, pairDelim, keyValueDelim)",
+          start = 7,
+          stop = 48)
+      )
+    }

Review Comment:
   we shouldn't use `DATATYPE_MISMATCH.DATA_DIFF_TYPES` for collation match 
verification
   
   please see `COLLATION_MISMATCH.EXPLICIT`, there should be many tests across 
the codebase market with "// Collation mismatch"



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