uros-db commented on code in PR #45643:
URL: https://github.com/apache/spark/pull/45643#discussion_r1565502312
##########
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:
let's keep the naming uniform
if the original expression is `case class StringInstr`, then this should
probably be:
`public static class IndexOf`
##########
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:
let's keep the naming uniform
if the original expression is `case class StringInstr`, then this should
probably be:
`public static class StringInstr`
--
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]