asdf2014 commented on a change in pull request #7224: Add ROUND function in 
druid-sql.
URL: https://github.com/apache/incubator-druid/pull/7224#discussion_r265396792
 
 

 ##########
 File path: core/src/main/java/org/apache/druid/math/expr/Function.java
 ##########
 @@ -450,9 +452,43 @@ public String name()
     }
 
     @Override
-    protected ExprEval eval(double param)
+    public ExprEval apply(List<Expr> args, Expr.ObjectBinding bindings)
     {
-      return ExprEval.of(Math.round(param));
+      if (args.size() == 1) {
+        ExprEval value1 = args.get(0).eval(bindings);
+        if (value1.type() != ExprType.LONG && value1.type() != 
ExprType.DOUBLE) {
+          throw new IAE("first argument should be integer or double type but 
got %s type", value1.type());
+        }
+        return eval(value1);
+      } else if (args.size() == 2) {
+        ExprEval value1 = args.get(0).eval(bindings);
+        ExprEval value2 = args.get(1).eval(bindings);
+        if (value1.type() != ExprType.LONG && value1.type() != 
ExprType.DOUBLE) {
+          throw new IAE("first argument should be integer or double type but 
got %s type", value1.type());
+        }
+        if (value2.type() != ExprType.LONG) {
+          throw new IAE("second argument should be integer type but got %s 
type", value2.type());
 
 Review comment:
   It would be better to add the function name to this error message. For 
example, `The second argument to the function[%s] should be integer type but 
get the %s type`.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to