uros-db commented on code in PR #45643: URL: https://github.com/apache/spark/pull/45643#discussion_r1565508312
########## common/unsafe/src/main/java/org/apache/spark/sql/catalyst/util/CollationSupport.java: ########## @@ -137,6 +137,76 @@ public static boolean execICU(final UTF8String l, final UTF8String r, } } + public static class FindInSet { + public static int exec(final UTF8String l, final UTF8String r, final int collationId) { + CollationFactory.Collation collation = CollationFactory.fetchCollation(collationId); + if (collation.supportsBinaryEquality) { + return execBinary(l, r); + } else if (collation.supportsLowercaseEquality) { + return execLowercase(l, r); + } else { + return execICU(l, r, collationId); + } + } + public static String genCode(final String l, final String r, final int collationId) { + CollationFactory.Collation collation = CollationFactory.fetchCollation(collationId); + String expr = "CollationSupport.FindInSet.exec"; + if (collation.supportsBinaryEquality) { + return String.format(expr + "Binary(%s, %s)", l, r); + } else if (collation.supportsLowercaseEquality) { + return String.format(expr + "Lowercase(%s, %s)", l, r); + } else { + return String.format(expr + "ICU(%s, %s, %d)", l, r, collationId); + } + } + public static int execBinary(final UTF8String l, final UTF8String r) { + return r.findInSet(l); + } + public static int execLowercase(final UTF8String l, final UTF8String r) { + return r.toLowerCase().findInSet(l.toLowerCase()); + } + public static int execICU(final UTF8String l, final UTF8String r, + final int collationId) { + return CollationAwareUTF8String.findInSet(l, r, collationId); + } + } + + public static class IndexOf { Review Comment: `CollationAwareUTF8String.indexOf` should follow the `UTF8String.indexOf` naming, so that part is fine for example but `CollationSupport.StringInstr` should definitely follow `stringExpressions.StringInstr` naming -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org