tanclary commented on code in PR #3648:
URL: https://github.com/apache/calcite/pull/3648#discussion_r1466752322
##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -6162,6 +6162,18 @@ void checkRegexpExtract(SqlOperatorFixture f0,
FunctionAlias functionAlias) {
f.checkNull("log10(cast(null as real))");
}
+ @Test void testLog2Func() {
+ final SqlOperatorFixture f = Fixtures.forOperators(true);
+ f.setFor(SqlStdOperatorTable.LOG2, VmName.EXPAND);
+ f.checkScalarApprox("log2(2)", "DOUBLE NOT NULL",
+ isWithin(1.0, 0.000001));
+ f.checkScalarApprox("log2(4)", "DOUBLE NOT NULL",
+ isWithin(2.0, 0.000001));
+ f.checkScalarApprox("log2(65536)", "DOUBLE NOT NULL",
Review Comment:
Can we add more tests:
with decimal arguments, negative arguments, maybe an expression (2 / 3)
##########
core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java:
##########
@@ -2764,7 +2764,7 @@ public static double power(BigDecimal b0, BigDecimal b1) {
}
- // LN, LOG, LOG10
+ // LN, LOG, LOG10, LOG2
Review Comment:
Is this a standard function? I see it supported for MySQL but no info on the
standard.
##########
site/_docs/reference.md:
##########
@@ -1335,6 +1335,7 @@ comp:
| MOD(numeric1, numeric2) | Returns the remainder (modulus) of *numeric1*
divided by *numeric2*. The result is negative only if *numeric1* is negative
| SQRT(numeric) | Returns the square root of *numeric*
| LN(numeric) | Returns the natural logarithm (base *e*) of
*numeric*
+| LOG2(numeric) | Returns the base 2 logarithm of *numeric*
Review Comment:
Earlier in the PR you prioritize LOG10 over LOG2, can you figure out the
correct alphabetical ordering and make it consistent throughout the PR?
--
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]