stefankandic commented on code in PR #49103:
URL: https://github.com/apache/spark/pull/49103#discussion_r1906987031


##########
common/utils/src/main/resources/error/error-conditions.json:
##########
@@ -1920,7 +1920,25 @@
   },
   "INDETERMINATE_COLLATION" : {
     "message" : [
-      "Function called requires knowledge of the collation it should apply, 
but indeterminate collation was found. Use COLLATE function to set the 
collation explicitly."
+      "Could not determine which collation to use for string operation. Use 
COLLATE clause to set the collation explicitly."
+    ],
+    "sqlState" : "42P22"
+  },
+  "INDETERMINATE_COLLATION_IN_EXPRESSION" : {
+    "message" : [
+      "Data type of <expr> has indeterminate collation. Use COLLATE clause to 
set the collation explicitly."
+    ],
+    "sqlState" : "42P22"
+  },
+  "INDETERMINATE_COLLATION_IN_SCHEMA" : {
+    "message" : [
+      "Schema contains indeterminate collation at: [<columnPaths>]. Use 
COLLATE clause to set the collation explicitly."
+    ],
+    "sqlState" : "42P22"
+  },
+  "INDETERMINATE_COLLATION_NOT_SERIALIZABLE" : {
+    "message" : [
+      "Indeterminate collation is not serializable. Use COLLATE clause to set 
the collation explicitly."

Review Comment:
   I removed this exception from the `jsonValue`. We don't have to check 
ADD/REPLACE COLUMN like for interval since we can't specify indeterminate 
collation in column definition. So we can just check at table create/write and 
at the creation of collation metadata.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CollationTypeCoercion.scala:
##########
@@ -38,10 +39,10 @@ object CollationTypeCoercion {
   }
 
   def apply(expression: Expression): Expression = expression match {
-    case ifExpr: If =>
-      ifExpr.withNewChildren(
-        ifExpr.predicate +: collateToSingleType(Seq(ifExpr.trueValue, 
ifExpr.falseValue))
-      )
+    case expr if shouldFailWithIndeterminateCollation(expr) =>
+      expr.failAnalysis(
+        errorClass = "INDETERMINATE_COLLATION_IN_EXPRESSION",
+        messageParameters = Map("expr" -> toSQLExpr(expr)))
 
     case caseWhenExpr: CaseWhen if 
!haveSameType(caseWhenExpr.inputTypesForMerging) =>

Review Comment:
   That is correct



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