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


##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationFactory.java:
##########
@@ -1154,9 +1154,33 @@ public static StringSearch getStringSearch(
    * Returns the collation ID for the given collation name.
    */
   public static int collationNameToId(String collationName) throws 
SparkException {
+    // If collation name is given as a fully qualified name, extract the 
actual collation name as
+    // the last part of the [catalog].[schema].[collation_name] name.
+    long numDots = collationName.chars().filter(ch -> ch == '.').count();
+    if (numDots > 0) {
+      String[] nameParts = collationName.split("\\.");
+      // Currently only predefined collations are supported.
+      if (numDots != 2 || 
!CollationFactory.CATALOG.equalsIgnoreCase(nameParts[0]) ||
+          !CollationFactory.SCHEMA.equalsIgnoreCase(nameParts[1])) {
+        throw 
CollationFactory.Collation.CollationSpec.collationInvalidNameException(collationName);

Review Comment:
   one other approach is to make sure that the suggestions algorithm returns 
fully qualified collation names at all times (although this might seem 
confusing to the user)



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