caicancai commented on code in PR #3689:
URL: https://github.com/apache/calcite/pull/3689#discussion_r1495195172
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -2788,6 +2788,18 @@ public static double log(BigDecimal d0, BigDecimal d1) {
return Math.log(d0.doubleValue()) / Math.log(d1.doubleValue());
}
+ /** SQL {@code LOG2(number)} function applied to double values. */
+ public static double log2(double d0) {
+ return (Double.isInfinite(log(d0, 2)) && d0 == 0.0) ? Double.NaN : log(d0,
2);
Review Comment:
Because - infinity and + infinity are special cases in SQL and do not
support parsing, so I added the condition here that d0 == 0. At present, only
the log2 (0) test is controversial.
--
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]