This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new b99ef07a3bf branch-2.1: [fix](Nereids) fix log and power #46077 (#46635) b99ef07a3bf is described below commit b99ef07a3bf866807cff3c86e5b4a5dbef9ed0db Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> AuthorDate: Wed Jan 8 22:31:22 2025 +0800 branch-2.1: [fix](Nereids) fix log and power #46077 (#46635) Cherry-picked from #46077 Co-authored-by: LiBinfeng <libinf...@selectdb.com> --- .../expressions/functions/executable/NumericArithmetic.java | 6 ++++++ .../doris/nereids/rules/expression/FoldConstantTest.java | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java index d739c830df2..6ab41167dc1 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java @@ -827,6 +827,9 @@ public class NumericArithmetic { @ExecFunction(name = "log") public static Expression log(DoubleLiteral first, DoubleLiteral second) { checkInputBoundary(first, 0.0d, Double.MAX_VALUE, false, true); + if (first.getValue().equals(1.0d)) { + throw new NotSupportedException("the first input of function log can not be 1.0"); + } return checkOutputBoundary(new DoubleLiteral(Math.log(first.getValue()) / Math.log(second.getValue()))); } @@ -863,6 +866,9 @@ public class NumericArithmetic { @ExecFunction(name = "power") public static Expression power(DoubleLiteral first, DoubleLiteral second) { checkInputBoundary(second, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false, false); + if (first.getValue() < 0 && second.getValue() % 1 != 0) { + throw new NotSupportedException("input pair of function power can not be negative number and non-integer"); + } return checkOutputBoundary(new DoubleLiteral(Math.pow(first.getValue(), second.getValue()))); } diff --git a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/FoldConstantTest.java b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/FoldConstantTest.java index 84b951ce951..a5dc39bfdd8 100644 --- a/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/FoldConstantTest.java +++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/rules/expression/FoldConstantTest.java @@ -49,6 +49,7 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.Floor; import org.apache.doris.nereids.trees.expressions.functions.scalar.FromUnixtime; import org.apache.doris.nereids.trees.expressions.functions.scalar.HoursAdd; import org.apache.doris.nereids.trees.expressions.functions.scalar.Ln; +import org.apache.doris.nereids.trees.expressions.functions.scalar.Log; import org.apache.doris.nereids.trees.expressions.functions.scalar.MinutesAdd; import org.apache.doris.nereids.trees.expressions.functions.scalar.Power; import org.apache.doris.nereids.trees.expressions.functions.scalar.Round; @@ -393,6 +394,11 @@ class FoldConstantTest extends ExpressionRewriteTestHelper { executor.rewrite(exExp, context); }, "input -1 is out of boundary"); + Assertions.assertThrows(NotSupportedException.class, () -> { + Log exExp = new Log(new DoubleLiteral(1.0d), new DoubleLiteral(1.0d)); + executor.rewrite(exExp, context); + }, "the first input of function log can not be 1.0"); + Sqrt sqrt = new Sqrt(new DoubleLiteral(16d)); rewritten = executor.rewrite(sqrt, context); Assertions.assertEquals(new DoubleLiteral(4d), rewritten); @@ -411,6 +417,10 @@ class FoldConstantTest extends ExpressionRewriteTestHelper { Power exExp = new Power(new DoubleLiteral(2d), new DoubleLiteral(10000d)); executor.rewrite(exExp, context); }, "infinite result is invalid"); + Assertions.assertThrows(NotSupportedException.class, () -> { + Power exExp = new Power(new DoubleLiteral(-1d), new DoubleLiteral(1.1d)); + executor.rewrite(exExp, context); + }, "input pair of function power can not be negative number and non-integer"); Sin sin = new Sin(new DoubleLiteral(Math.PI / 2)); rewritten = executor.rewrite(sin, context); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org