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


##########
common/unsafe/src/main/java/org/apache/spark/unsafe/types/UTF8String.java:
##########
@@ -343,19 +346,33 @@ public boolean contains(final UTF8String substring) {
     return false;
   }
 
-  public boolean contains(final UTF8String substring, int collationId) throws 
SparkException {
+  public boolean contains(final UTF8String substring, int collationId) {
     if (CollationFactory.fetchCollation(collationId).isBinaryCollation) {
       return this.contains(substring);
     }
     if (collationId == CollationFactory.LOWERCASE_COLLATION_ID) {
       return this.toLowerCase().contains(substring.toLowerCase());
     }
-    // TODO: enable ICU collation support for "contains" (SPARK-47248)
-    Map<String, String> params = new HashMap<>();
-    params.put("functionName", "contains");
-    params.put("collationName", 
CollationFactory.fetchCollation(collationId).collationName);
-    throw new SparkException("UNSUPPORTED_COLLATION.FOR_FUNCTION",
-            SparkException.constructMessageParams(params), null);
+    return collatedStringSearch(substring, collationId);
+  }
+
+  private boolean collatedStringSearch(final UTF8String substring, int 
collationId) {
+    if (substring.numBytes == 0) {
+      return true;
+    } else if (this.numBytes == 0) {
+      return false;
+    }
+    String pattern = substring.toString();
+    CharacterIterator target = new StringCharacterIterator(this.toString());
+    Collator collator = CollationFactory.fetchCollation(collationId).collator;
+    StringSearch stringSearch = new StringSearch(pattern, target, 
(RuleBasedCollator) collator);
+    stringSearch.reset();

Review Comment:
   indeed, removed



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