diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java index 6a0473037925..d5b008086663 100644 --- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java +++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java @@ -211,7 +211,7 @@ import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOG2; import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOGICAL_AND; import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOGICAL_OR; -import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOG_MYSQL_SPARK; +import static org.apache.calcite.sql.fun.SqlLibraryOperators.LOG_MYSQL; import static org.apache.calcite.sql.fun.SqlLibraryOperators.LPAD; import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP; import static org.apache.calcite.sql.fun.SqlLibraryOperators.MAP_CONCAT; @@ -649,10 +649,10 @@ Builder populate() { map.put(LOG, logImplementor); map.put(LOG10, logImplementor); - LogImplementor logMysqlSparkImplementor = - new LogImplementor(BuiltInMethod.LOG_MYSQL_SPARK.method); - map.put(LOG_MYSQL_SPARK, logMysqlSparkImplementor); - map.put(LOG2, logMysqlSparkImplementor); + LogImplementor logMysqlImplementor = + new LogImplementor(BuiltInMethod.LOG_MYSQL.method); + map.put(LOG_MYSQL, logMysqlImplementor); + map.put(LOG2, logMysqlImplementor); defineReflective(RAND, BuiltInMethod.RAND.method, BuiltInMethod.RAND_SEED.method); diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java index 23b5c6215031..ec04c8624525 100644 --- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java +++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java @@ -2790,26 +2790,26 @@ public static double log(BigDecimal d0, BigDecimal d1) { /** SQL {@code LOG(number, number2)} function applied to double values. * but return null when number2 is 0. */ - public static @Nullable Double logMysqlSpark(double number, double number2) { + public static @Nullable Double logMysql(double number, double number2) { return (number <= 0) ? null : log(number, number2); } /** SQL {@code LOG(number, number2)} function applied to double and BigDecimal values. * but return null when number2 is 0. */ - public static @Nullable Double logMysqlSpark(double number, BigDecimal number2) { - return logMysqlSpark(number, number2.doubleValue()); + public static @Nullable Double logMysql(double number, BigDecimal number2) { + return logMysql(number, number2.doubleValue()); } /** SQL {@code LOG(number, number2)} function applied to BigDecimal and double values. * but return null when number2 is 0. */ - public static @Nullable Double logMysqlSpark(BigDecimal number, double number2) { - return logMysqlSpark(number.doubleValue(), number2); + public static @Nullable Double logMysql(BigDecimal number, double number2) { + return logMysql(number.doubleValue(), number2); } /** SQL {@code LOG(number, number2)} function applied to double values. * but return null when number2 is 0. */ - public static @Nullable Double logMysqlSpark(BigDecimal number, BigDecimal number2) { - return logMysqlSpark(number.doubleValue(), number2.doubleValue()); + public static @Nullable Double logMysql(BigDecimal number, BigDecimal number2) { + return logMysql(number.doubleValue(), number2.doubleValue()); } // MOD diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java index 5f2b4ddbcc46..91b9e8722148 100644 --- a/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java +++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlLibraryOperators.java @@ -2207,7 +2207,7 @@ private static RelDataType deriveTypeMapFromEntries(SqlOperatorBinding opBinding /** The "LOG(numeric1, numeric2)" function. Returns the base numeric1 logarithm of numeric. */ @LibraryOperator(libraries = {MYSQL, SPARK}) - public static final SqlFunction LOG_MYSQL_SPARK = + public static final SqlFunction LOG_MYSQL = SqlBasicFunction.create("LOG", ReturnTypes.DOUBLE_FORCE_NULLABLE, OperandTypes.NUMERIC_OPTIONAL_NUMERIC, diff --git a/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java b/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java index be357c505e36..53dad1296f5f 100644 --- a/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java +++ b/core/src/main/java/org/apache/calcite/util/BuiltInMethod.java @@ -512,7 +512,7 @@ public enum BuiltInMethod { SAFE_MULTIPLY(SqlFunctions.class, "safeMultiply", double.class, double.class), SAFE_SUBTRACT(SqlFunctions.class, "safeSubtract", double.class, double.class), LOG(SqlFunctions.class, "log", long.class, long.class), - LOG_MYSQL_SPARK(SqlFunctions.class, "logMysqlSpark", long.class, long.class), + LOG_MYSQL(SqlFunctions.class, "logMysql", long.class, long.class), SEC(SqlFunctions.class, "sec", double.class), SECH(SqlFunctions.class, "sech", double.class), SIGN(SqlFunctions.class, "sign", long.class), diff --git a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java index d72c03e4e2a2..01ff3a35fca6 100644 --- a/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java +++ b/testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java @@ -6341,11 +6341,11 @@ void checkRegexpExtract(SqlOperatorFixture f0, FunctionAlias functionAlias) { /** Test case for * [CALCITE-6325] * Add LOG function (enabled in MYSQL library). */ - @Test void testLogMysqlSparkFunc() { + @Test void testLogMysqlFunc() { final SqlOperatorFixture f0 = fixture(); f0.checkFails("^log(100, 10)^", "No match found for function signature LOG\\(, \\)", false); - f0.setFor(SqlLibraryOperators.LOG_MYSQL_SPARK); + f0.setFor(SqlLibraryOperators.LOG_MYSQL); final Consumer consumer = f -> { f.checkScalarApprox("log(10, 10)", "DOUBLE", isWithin(1.0, 0.000001));