KKcorps commented on a change in pull request #8304: URL: https://github.com/apache/pinot/pull/8304#discussion_r834759693
########## File path: pinot-common/src/main/java/org/apache/pinot/common/function/scalar/ArithmeticFunctions.java ########## @@ -104,4 +106,46 @@ public static double ln(double a) { public static double sqrt(double a) { return Math.sqrt(a); } + + @ScalarFunction + public static double sign(double a) { + return Math.signum(a); + } + + @ScalarFunction + public static double power(double a, double b) { + return Math.pow(a, b); + } + + @ScalarFunction + public static double log2(double a) { + return Math.log(a) / Math.log(2); + } + + @ScalarFunction + public static double log10(double a) { + return Math.log10(a); + } + + //TODO: The function should ideally be named 'round' + // but it is not possible because of existing DateTimeFunction with same name. + @ScalarFunction + public static double roundDecimal(double a, int b) { + return BigDecimal.valueOf(a).setScale(b, RoundingMode.HALF_UP).doubleValue(); + } + + @ScalarFunction + public static double roundDecimal(double a) { + return BigDecimal.valueOf(a).setScale(0, RoundingMode.HALF_UP).doubleValue(); + } + + @ScalarFunction + public static double truncate(double a, int b) { + return BigDecimal.valueOf(a).setScale(b, RoundingMode.DOWN).doubleValue(); Review comment: I think it already does that. Can you point me to a case where this will fail? -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org