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


##########
common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationFactory.java:
##########
@@ -917,16 +957,35 @@ protected Collation buildCollation() {
         Collator collator = Collator.getInstance(resultLocale);
         // Freeze ICU collator to ensure thread safety.
         collator.freeze();
+
+        Comparator<UTF8String> comparator;
+        ToLongFunction<UTF8String> hashFunction;
+
+        if(spaceTrimming == SpaceTrimming.NONE){
+          hashFunction = s -> (long) collator.getCollationKey(
+                  s.toValidString()).hashCode();
+          comparator = (s1, s2) ->
+                  collator.compare(s1.toValidString(), s2.toValidString());
+        } else {
+          comparator = (s1, s2) -> collator.compare(
+                  applyTrimmingPolicy(s1, spaceTrimming).toValidString(),
+                  applyTrimmingPolicy(s2, spaceTrimming).toValidString());

Review Comment:
   ```suggestion
             comparator = (s1, s2) -> collator.compare(
               applyTrimmingPolicy(s1, spaceTrimming).toValidString(),
               applyTrimmingPolicy(s2, spaceTrimming).toValidString());
   ```



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