Jackie-Jiang commented on code in PR #16276:
URL: https://github.com/apache/pinot/pull/16276#discussion_r2208901600


##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/regexp/RegexpLikeConstFunctions.java:
##########
@@ -34,17 +35,53 @@ public class RegexpLikeConstFunctions {
   @ScalarFunction
   public boolean regexpLike(String inputStr, String regexPatternStr) {
     if (_matcher == null) {
-      _matcher = PatternFactory.compile(regexPatternStr).matcher("");
+      Pattern p = PatternFactory.compile(regexPatternStr);
+      _matcher = p.matcher("");

Review Comment:
   (minor) We can chain the calls to be more concise. Same for other calls and 
classes



##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/regexp/RegexpLikeConstFunctions.java:
##########
@@ -34,17 +35,54 @@ public class RegexpLikeConstFunctions {
   @ScalarFunction
   public boolean regexpLike(String inputStr, String regexPatternStr) {
     if (_matcher == null) {
-      _matcher = PatternFactory.compile(regexPatternStr).matcher("");
+      Pattern p = PatternFactory.compile(regexPatternStr);
+      _matcher = p.matcher("");
     }
 
     return _matcher.reset(inputStr).find();
   }
 
+  @ScalarFunction
+  public boolean regexpLike(String inputStr, String regexPatternStr, String 
matchParameter) {
+    if (_matcher == null) {
+      Pattern p = buildPattern(regexPatternStr, matchParameter);
+      _matcher = p.matcher("");
+    }
+
+    return _matcher.reset(inputStr).find();
+  }
+
+  private Pattern buildPattern(String pattern, String matchParameter) {
+    // Validate that all characters in matchParameter are supported
+    for (char c : matchParameter.toCharArray()) {

Review Comment:
   Given we only allow `'i'` or `'c'` as the match parameter, consider 
simplifying the handling to:
   - Check single character
   - Check character is `'i'` or `'c'` or throw exception



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