cloud-fan commented on code in PR #45946:
URL: https://github.com/apache/spark/pull/45946#discussion_r1561965680
##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationFactory.java:
##########
@@ -202,6 +202,22 @@ public static StringSearch getStringSearch(
return new StringSearch(pattern, target, (RuleBasedCollator) collator);
}
+ /**
+ * Returns if the given collationName is valid one.
+ */
+ public static boolean isValidCollation(String collationName) {
+ return collationNameToIdMap.containsKey(collationName.toUpperCase());
+ }
+
+ /**
+ * Returns closest valid name to collationName
+ */
+ public static String getClosestCollation(String collationName) {
+ Collation suggestion = Collections.min(List.of(collationTable),
Comparator.comparingInt(
+ c -> UTF8String.fromString(c.collationName).levenshteinDistance(
+ UTF8String.fromString(collationName.toUpperCase()))));
+ return suggestion.collationName;
Review Comment:
are we missing a closing `}`?
##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationFactory.java:
##########
@@ -211,6 +227,7 @@ public static StringSearch getStringSearch(
final UTF8String targetUTF8String,
final UTF8String patternUTF8String) {
return new StringSearch(patternUTF8String.toString(),
targetUTF8String.toString());
+
Review Comment:
```suggestion
```
--
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]