diff --git a/presto-main/src/main/java/com/facebook/presto/metadata/FunctionRegistry.java b/presto-main/src/main/java/com/facebook/presto/metadata/FunctionRegistry.java index 4a64595293d55..19855e812ab1e 100644 --- a/presto-main/src/main/java/com/facebook/presto/metadata/FunctionRegistry.java +++ b/presto-main/src/main/java/com/facebook/presto/metadata/FunctionRegistry.java @@ -112,7 +112,6 @@ import com.facebook.presto.operator.scalar.MapSubscriptOperator; import com.facebook.presto.operator.scalar.MapValues; import com.facebook.presto.operator.scalar.MathFunctions; -import com.facebook.presto.operator.scalar.MathFunctions.LegacyLogFunction; import com.facebook.presto.operator.scalar.MultimapFromEntriesFunction; import com.facebook.presto.operator.scalar.QuantileDigestFunctions; import com.facebook.presto.operator.scalar.Re2JRegexpFunctions; @@ -657,10 +656,6 @@ public FunctionRegistry(TypeManager typeManager, BlockEncodingSerde blockEncodin break; } - if (featuresConfig.isLegacyLogFunction()) { - builder.scalar(LegacyLogFunction.class); - } - addFunctions(builder.getFunctions()); if (typeManager instanceof TypeRegistry) { diff --git a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java index 746eb1f7d2f97..6729224907f29 100644 --- a/presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java +++ b/presto-main/src/main/java/com/facebook/presto/operator/scalar/MathFunctions.java @@ -161,19 +161,6 @@ public static Slice absLong(@SqlType("decimal(p, s)") Slice arg) } } - @ScalarFunction("log") - @Description("logarithm to given base") - public static final class LegacyLogFunction - { - private LegacyLogFunction() {} - - @SqlType(StandardTypes.DOUBLE) - public static double log(@SqlType(StandardTypes.DOUBLE) double number, @SqlType(StandardTypes.DOUBLE) double base) - { - return Math.log(number) / Math.log(base); - } - } - @Description("absolute value") @ScalarFunction("abs") @SqlType(StandardTypes.REAL) @@ -466,6 +453,14 @@ public static double ln(@SqlType(StandardTypes.DOUBLE) double num) return Math.log(num); } + @Description("logarithm to given base") + @ScalarFunction + @SqlType(StandardTypes.DOUBLE) + public static double log(@SqlType(StandardTypes.DOUBLE) double base, @SqlType(StandardTypes.DOUBLE) double number) + { + return Math.log(number) / Math.log(base); + } + @Description("logarithm to base 2") @ScalarFunction @SqlType(StandardTypes.DOUBLE) diff --git a/presto-main/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java b/presto-main/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java index a96da25fd3f8c..1dcf48ec38fd6 100644 --- a/presto-main/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java +++ b/presto-main/src/main/java/com/facebook/presto/sql/analyzer/FeaturesConfig.java @@ -82,7 +82,6 @@ public class FeaturesConfig private boolean pushTableWriteThroughUnion = true; private boolean exchangeCompressionEnabled; private boolean legacyArrayAgg; - private boolean legacyLogFunction; private boolean groupByUsesEqualTo; private boolean legacyTimestamp = true; private boolean legacyMapSubscript; @@ -233,18 +232,6 @@ public boolean isLegacyArrayAgg() return legacyArrayAgg; } - @Config("deprecated.legacy-log-function") - public FeaturesConfig setLegacyLogFunction(boolean value) - { - this.legacyLogFunction = value; - return this; - } - - public boolean isLegacyLogFunction() - { - return legacyLogFunction; - } - @Config("deprecated.group-by-uses-equal") public FeaturesConfig setGroupByUsesEqualTo(boolean value) { diff --git a/presto-main/src/test/java/com/facebook/presto/operator/scalar/AbstractTestFunctions.java b/presto-main/src/test/java/com/facebook/presto/operator/scalar/AbstractTestFunctions.java index ec2e489c8e948..a6217bfd7ebc8 100644 --- a/presto-main/src/test/java/com/facebook/presto/operator/scalar/AbstractTestFunctions.java +++ b/presto-main/src/test/java/com/facebook/presto/operator/scalar/AbstractTestFunctions.java @@ -75,7 +75,7 @@ protected AbstractTestFunctions(FeaturesConfig config) protected AbstractTestFunctions(Session session, FeaturesConfig config) { this.session = requireNonNull(session, "session is null"); - this.config = requireNonNull(config, "config is null").setLegacyLogFunction(true); + this.config = requireNonNull(config, "config is null"); } @BeforeClass diff --git a/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestMathFunctions.java b/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestMathFunctions.java index 4efcbe60b6ed4..a9d76c810af58 100644 --- a/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestMathFunctions.java +++ b/presto-main/src/test/java/com/facebook/presto/operator/scalar/TestMathFunctions.java @@ -478,8 +478,8 @@ public void testLog() { for (double doubleValue : DOUBLE_VALUES) { for (double base : DOUBLE_VALUES) { - assertFunction("log(" + doubleValue + ", " + base + ")", DOUBLE, Math.log(doubleValue) / Math.log(base)); - assertFunction("log(REAL '" + (float) doubleValue + "', REAL'" + (float) base + "')", DOUBLE, Math.log((float) doubleValue) / Math.log((float) base)); + assertFunction("log(" + base + ", " + doubleValue + ")", DOUBLE, Math.log(doubleValue) / Math.log(base)); + assertFunction("log(REAL '" + (float) base + "', REAL'" + (float) doubleValue + "')", DOUBLE, Math.log((float) doubleValue) / Math.log((float) base)); } } assertFunction("log(NULL, NULL)", DOUBLE, null); diff --git a/presto-main/src/test/java/com/facebook/presto/sql/analyzer/TestFeaturesConfig.java b/presto-main/src/test/java/com/facebook/presto/sql/analyzer/TestFeaturesConfig.java index 45c68e3d62ae7..ed94790b9ed57 100644 --- a/presto-main/src/test/java/com/facebook/presto/sql/analyzer/TestFeaturesConfig.java +++ b/presto-main/src/test/java/com/facebook/presto/sql/analyzer/TestFeaturesConfig.java @@ -82,7 +82,6 @@ public void testDefaults() .setMemoryRevokingThreshold(0.9) .setMemoryRevokingTarget(0.5) .setOptimizeMixedDistinctAggregations(false) - .setLegacyLogFunction(false) .setIterativeOptimizerEnabled(true) .setIterativeOptimizerTimeout(new Duration(3, MINUTES)) .setEnableStatsCalculator(true) @@ -123,7 +122,6 @@ public void testExplicitPropertyMappings() .put("optimizer.ignore-stats-calculator-failures", "false") .put("optimizer.default-filter-factor-enabled", "true") .put("deprecated.legacy-array-agg", "true") - .put("deprecated.legacy-log-function", "true") .put("deprecated.group-by-uses-equal", "true") .put("deprecated.legacy-map-subscript", "true") .put("deprecated.legacy-row-field-ordinal-access", "true") @@ -218,7 +216,6 @@ public void testExplicitPropertyMappings() .setSpillMaxUsedSpaceThreshold(0.8) .setMemoryRevokingThreshold(0.2) .setMemoryRevokingTarget(0.8) - .setLegacyLogFunction(true) .setExchangeCompressionEnabled(true) .setLegacyTimestamp(false) .setLegacyRowFieldOrdinalAccess(true) diff --git a/presto-tests/src/test/java/com/facebook/presto/tests/TestLegacyLogFunction.java b/presto-tests/src/test/java/com/facebook/presto/tests/TestLegacyLogFunction.java deleted file mode 100644 index fac10102b21e2..0000000000000 --- a/presto-tests/src/test/java/com/facebook/presto/tests/TestLegacyLogFunction.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.tests; - -import com.facebook.presto.sql.analyzer.FeaturesConfig; -import com.facebook.presto.sql.analyzer.SemanticException; -import com.facebook.presto.testing.LocalQueryRunner; -import com.facebook.presto.testing.MaterializedResult; -import com.facebook.presto.testing.QueryRunner; -import org.testng.annotations.Test; - -import static com.facebook.presto.testing.TestingSession.testSessionBuilder; -import static org.testng.Assert.assertEquals; - -// run single threaded to avoid creating multiple query runners at once -@Test(singleThreaded = true) -public class TestLegacyLogFunction -{ - private static final String QUERY = "SELECT LOG(25, 5)"; - - @Test - public void testLegacyLogFunctionEnabled() - { - try (QueryRunner queryRunner = createQueryRunner(true)) { - MaterializedResult result = queryRunner.execute(QUERY); - assertEquals(result.getOnlyValue(), 2.0); - } - } - - @Test(expectedExceptions = {SemanticException.class}, - expectedExceptionsMessageRegExp = ".*Function log not registered") - public void testLegacyLogFunctionDisabled() - { - try (QueryRunner runner = createQueryRunner(false)) { - runner.execute(QUERY); - } - } - - private static QueryRunner createQueryRunner(boolean legacyLogFunction) - { - return new LocalQueryRunner(testSessionBuilder().build(), - new FeaturesConfig().setLegacyLogFunction(legacyLogFunction)); - } -}