dbatomic commented on code in PR #45592:
URL: https://github.com/apache/spark/pull/45592#discussion_r1530447723


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/literals.scala:
##########
@@ -69,10 +69,41 @@ object Literal {
     case f: Float => Literal(f, FloatType)
     case b: Byte => Literal(b, ByteType)
     case s: Short => Literal(s, ShortType)
-    case s: String => Literal(UTF8String.fromString(s), StringType)
-    case s: UTF8String => Literal(s, StringType)
-    case c: Char => Literal(UTF8String.fromString(c.toString), StringType)
-    case ac: Array[Char] => Literal(UTF8String.fromString(String.valueOf(ac)), 
StringType)
+    case s: String =>
+      if (CollationFactory.collationNameToId(SQLConf.get.defaultCollation)
+        == CollationFactory.SPARK_INTERNAL_COLLATION_ID) {
+        Literal(UTF8String.fromString(s), StringType)
+      }
+      else {
+        Literal(UTF8String.fromString(s),
+          
StringType(CollationFactory.collationNameToId(SQLConf.get.defaultCollation)))
+      }
+    case s: UTF8String =>
+      if (CollationFactory.collationNameToId(SQLConf.get.defaultCollation)
+        == CollationFactory.SPARK_INTERNAL_COLLATION_ID) {
+        Literal(s, StringType)
+      }
+      else {
+        Literal(s, 
StringType(CollationFactory.collationNameToId(SQLConf.get.defaultCollation)))

Review Comment:
   IMO we should keep interallly `defaultCollation` as an integer but expose it 
to customer as a string (e.g. on SET defaultCollation customer should see 
collation name).
   
   That should also make this code a bit nicer - just `Literal(s, 
StringType(SQLConf.get.defaultCollationId))`.



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