somu-imply commented on a change in pull request #11904:
URL: https://github.com/apache/druid/pull/11904#discussion_r749820435
##########
File path: core/src/main/java/org/apache/druid/math/expr/Function.java
##########
@@ -1165,6 +1165,53 @@ protected ExprEval eval(double param)
}
}
+ class SafeDivide extends BivariateMathFunction
+ {
+ public static final String NAME = "safe_divide";
+
+ @Override
+ public String name()
+ {
+ return NAME ;
+ }
+
+ @Nullable
+ @Override
+ public ExpressionType getOutputType(Expr.InputBindingInspector inspector,
List<Expr> args)
+ {
+ ExpressionType type = ExpressionType.DOUBLE;
+ for (Expr arg : args) {
+ type = ExpressionTypeConversion.function(type,
arg.getOutputType(inspector));
+ }
+ return ExpressionType.asArrayType(type);
Review comment:
Done
##########
File path: docs/misc/math-expr.md
##########
@@ -154,6 +154,7 @@ See javadoc of java.lang.Math for detailed explanation for
each function.
|remainder|remainder(x, y) returns the remainder operation on two arguments as
prescribed by the IEEE 754 standard|
|rint|rint(x) returns value that is closest in value to x and is equal to a
mathematical integer|
|round|round(x, y) returns the value of the x rounded to the y decimal places.
While x can be an integer or floating-point number, y must be an integer. The
type of the return value is specified by that of x. y defaults to 0 if omitted.
When y is negative, x is rounded on the left side of the y decimal points. If x
is `NaN`, x returns 0. If x is infinity, x will be converted to the nearest
finite double. |
+|safe_divide|safe_divide(x,y) returns the division of x by y if y is not equal
to 0. In case y is 0 it returns null or default values (if returning default
values are enabled). |
Review comment:
Done
--
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]