github-advanced-security[bot] commented on code in PR #18281:
URL: https://github.com/apache/druid/pull/18281#discussion_r2215250557


##########
processing/src/main/java/org/apache/druid/query/expression/RegexpLikeExprMacro.java:
##########
@@ -45,49 +45,92 @@
   public Expr apply(final List<Expr> args)
   {
     validationHelperCheckArgumentCount(args, 2);
+    if (ExprUtils.isStringLiteral(args.get(1))) {
+      return new RegexpLikeExpr(args);
+    } else {
+      return new RegexpLikeDynamicExpr(args);
+    }
+  }
 
-    final Expr arg = args.get(0);
-    final Expr patternExpr = args.get(1);
+  abstract class BaseRegexpLikeExpr extends 
ExprMacroTable.BaseScalarMacroFunctionExpr

Review Comment:
   ## Inner class could be static
   
   BaseRegexpLikeExpr could be made static, since the enclosing instance is 
used only in its constructor.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/9917)



##########
processing/src/main/java/org/apache/druid/query/expression/RegexpLikeExprMacro.java:
##########
@@ -45,49 +45,92 @@
   public Expr apply(final List<Expr> args)
   {
     validationHelperCheckArgumentCount(args, 2);
+    if (ExprUtils.isStringLiteral(args.get(1))) {
+      return new RegexpLikeExpr(args);
+    } else {
+      return new RegexpLikeDynamicExpr(args);
+    }
+  }
 
-    final Expr arg = args.get(0);
-    final Expr patternExpr = args.get(1);
+  abstract class BaseRegexpLikeExpr extends 
ExprMacroTable.BaseScalarMacroFunctionExpr
+  {
+    public BaseRegexpLikeExpr(final List<Expr> args)
+    {
+      super(RegexpLikeExprMacro.this, args);
+    }
 
-    if (!ExprUtils.isStringLiteral(patternExpr)) {
-      throw validationFailed("pattern must be a STRING literal");
+    @Nullable
+    @Override
+    public ExpressionType getOutputType(InputBindingInspector inspector)
+    {
+      return ExpressionType.LONG;
     }
+  }
 
-    // Precompile the pattern.
-    final Pattern pattern = Pattern.compile(
-        StringUtils.nullToEmptyNonDruidDataString((String) 
patternExpr.getLiteralValue())
-    );
+  /**
+   * Expr when pattern is a literal.
+   */
+  class RegexpLikeExpr extends BaseRegexpLikeExpr

Review Comment:
   ## Inner class could be static
   
   RegexpLikeExpr could be made static, since the enclosing instance is used 
only in its constructor.
   
   [Show more 
details](https://github.com/apache/druid/security/code-scanning/9918)



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