tanclary commented on code in PR #3689: URL: https://github.com/apache/calcite/pull/3689#discussion_r1502085356
########## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ########## @@ -2788,6 +2788,17 @@ 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. */ Review Comment: in the comment you call the parameter "number" but in the actual method you call it "d0", these should be consistent. ########## core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java: ########## @@ -2788,6 +2788,17 @@ 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 @Nullable Double log2(double d0) { + return (d0 <= 0) ? null : log(d0, 2); + } + + /** SQL {@code LOG2(number)} function applied to Review Comment: same comment as above ########## core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java: ########## @@ -2149,6 +2149,18 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding OperandTypes.NUMERIC_OPTIONAL_NUMERIC, SqlFunctionCategory.NUMERIC); + /** The "LOG2(value)" function. + * + * @see SqlStdOperatorTable#LN Review Comment: Why "@see" these other functions? They're not the same. I think a brief description would be more helpful. ########## core/src/main/java/org/apache/calcite/sql/type/ReturnTypes.java: ########## @@ -396,6 +396,13 @@ public static SqlCall stripSeparator(SqlCall call) { public static final SqlReturnTypeInference DOUBLE_NULLABLE = DOUBLE.andThen(SqlTypeTransforms.TO_NULLABLE); + /** + * Type-inference strategy whereby the result type of a call is a nullable + * Double. Review Comment: Going forward if someone writes some code for you it's good practice to add them as a co-author. Don't worry about it for me but other people may want their work attributed to them. -- 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...@calcite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org