clintropolis commented on a change in pull request #7388: Support LPAD and RPAD 
sql function
URL: https://github.com/apache/incubator-druid/pull/7388#discussion_r271465238
 
 

 ##########
 File path: core/src/main/java/org/apache/druid/math/expr/Function.java
 ##########
 @@ -1206,4 +1206,61 @@ public ExprEval apply(List<Expr> args, 
Expr.ObjectBinding bindings)
       return ExprEval.of(expr.value() != null, ExprType.LONG);
     }
   }
+
+  class LpadFunc implements Function
+  {
+    @Override
+    public String name()
+    {
+      return "lpad";
+    }
+
+    @Override
+    public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
+    {
+      if (args.size() != 3) {
+        throw new IAE("Function[%s] needs 3 arguments", name());
+      }
+      
+      String base = 
NullHandling.nullToEmptyIfNeeded(args.get(0).eval(bindings).asString());
 
 Review comment:
   Does it make sense to pad empty values when sql compatible null handling is 
not enabled?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to