tanclary commented on code in PR #3648:
URL: https://github.com/apache/calcite/pull/3648#discussion_r1474685867


##########
testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java:
##########
@@ -6188,6 +6188,65 @@ void checkRegexpExtract(SqlOperatorFixture f0, 
FunctionAlias functionAlias) {
     f.checkNull("log(10, cast(null as real))");
   }
 
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6224";>[CALCITE-6224]
+   * Add LOG@ function (enabled in MYSQL, Spark library)</a>. */
+  @Test void testLog2Func() {
+    final SqlOperatorFixture f0 = fixture();
+    final Consumer<SqlOperatorFixture> consumer = f -> {
+      f.setFor(SqlLibraryOperators.LOG2);
+      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",
+          isWithin(16.0, 0.000001));
+      f.checkScalarApprox("log2(-2)", "DOUBLE NOT NULL",
+          "NaN");
+      f.checkScalarApprox("log2(2/3)", "DOUBLE NOT NULL",
+          "-Infinity");
+      f.checkScalarApprox("log2(2.2)", "DOUBLE NOT NULL",
+          "1.1375035237499351");
+      f.checkScalarApprox("log2(0.5)", "DOUBLE NOT NULL",
+          "-1.0");
+      f.checkScalarApprox("log2(3)", "DOUBLE NOT NULL",
+          isWithin(1.5849625007211563, 0.000001));
+      f.checkNull("log2(cast(null as real))");
+    };
+    f0.forEachLibrary(list(SqlLibrary.MYSQL, SqlLibrary.SPARK), consumer);
+  }
+
+  /** Test case for
+   * <a 
href="https://issues.apache.org/jira/browse/CALCITE-6232";>[CALCITE-6232]
+   * Using fractions in LOG function does not return correct results</a>. */
+  @Test void testLogFuncByConvert() {
+    // The fractional conversion of the Log function is reserved only for 
integer bits
+    final SqlOperatorFixture f0 = Fixtures.forOperators(true);
+    f0.setFor(SqlLibraryOperators.LOG, VmName.EXPAND);
+    final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.BIG_QUERY);
+    f.checkScalarApprox("log(2/3, 2)", "DOUBLE NOT NULL",
+          "-Infinity");
+    f.checkScalarApprox("log(0,2)", "DOUBLE NOT NULL",
+          "-Infinity");
+    f.checkScalarApprox("log(1,2)", "DOUBLE NOT NULL",
+        "0.0");
+    f.checkScalarApprox("log(4/3,2)", "DOUBLE NOT NULL",
+        "0.0");
+    f.checkScalarApprox("log(5/3,2)", "DOUBLE NOT NULL",
+        "0.0");
+    f.checkScalarApprox("log(2/3, 10)", "DOUBLE NOT NULL",
+          "-Infinity");
+    f.checkScalarApprox("log(0,10)", "DOUBLE NOT NULL",
+          "-Infinity");
+    f.checkScalarApprox("log(1,10)", "DOUBLE NOT NULL",
+        "0.0");
+    f.checkScalarApprox("log(4/3,10)", "DOUBLE NOT NULL",

Review Comment:
   Why don't we fix the bug? Do you have an updated JIRA case for it?



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

Reply via email to