caicancai commented on code in PR #3689:
URL: https://github.com/apache/calcite/pull/3689#discussion_r1495163992


##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -2790,13 +2790,13 @@ public static double log(BigDecimal d0, BigDecimal d1) {
 
   /** SQL {@code LOG2(number)} function applied to double values. */
   public static double log2(double d0) {
-    return (d0 == 0) ? Double.NaN : Math.log(d0) / Math.log(2);
+    return (Double.isInfinite(log(d0, 2))) ? Double.NaN : log(d0, 2);

Review Comment:
   > I don't think this will work for the case of +infinity. You should add a 
test case for `log2(CAST "+Infinity' AS NULL)`. I expect that the result will 
be NaN, whereas you probably expect Infinity in that case. So you should also 
check that the infinity is negative here.
   
   Maybe I should check how mysql and spark work



-- 
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]

Reply via email to