Skip to content

Commit ed8a4cf

Browse files
branch-3.0: [fix](nereids) fix tanh cosntant folding #52100 (#52526)
Cherry-picked from #52100 Co-authored-by: admiring_xm <[email protected]>
1 parent ecb241a commit ed8a4cf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/NumericArithmetic.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ public static Expression cosh(DoubleLiteral first) {
10501050
/**
10511051
* tanh
10521052
*/
1053-
@ExecFunction(name = "cosh")
1053+
@ExecFunction(name = "tanh")
10541054
public static Expression tanh(DoubleLiteral first) {
10551055
return checkOutputBoundary(new DoubleLiteral(Math.tanh(first.getValue())));
10561056
}

regression-test/suites/nereids_p0/expression/fold_constant/fold_constant_numeric_arithmatic.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ suite("fold_constant_numeric_arithmatic") {
470470
testFoldConst("SELECT TANH(0) AS tanh_case_1") //tanh(0) = 0
471471
testFoldConst("SELECT TANH(1) AS tanh_case_2") //tanh(1)
472472
testFoldConst("SELECT TANH(-1) AS tanh_case_3") //tanh(-1)
473+
testFoldConst("SELECT TANH(NULL)")
474+
testFoldConst("SELECT TANH(-0.5), TANH(0.5), TANH(10), TANH(-10)")
475+
testFoldConst("SELECT TANH(-20), TANH(20), TANH(1E-7), TANH(-1E-7)")
473476

474477
//Truncate function cases
475478
testFoldConst("SELECT TRUNCATE(123.456, 2) AS truncate_case_1") //truncate(123.456, 2) = 123.45

0 commit comments

Comments
 (0)