You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/04/02 19:43:50 UTC
[GitHub] [incubator-druid] clintropolis commented on a change in pull
request #7388: Support LPAD and RPAD sql function
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_r271464484
##########
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());
+ int len = args.get(1).eval(bindings).asInt();
+ String pad = NullHandling.nullToEmptyIfNeeded(args.get(2).eval(bindings).asString());
Review comment:
Does this make sense for the `pad`? Seems like it should maybe be an error if it's null?
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org