branch-2.1: [fix](nereids) fix tanh cosntant folding #52100 (#52527)

Cherry-picked from #52100

Co-authored-by: admiring_xm <86338598+wumeibanfa@users.noreply.github.com>
This commit is contained in:
github-actions[bot]
2025-07-02 10:21:10 +08:00
committed by GitHub
parent 794982a668
commit 06bbfd1eea
2 changed files with 4 additions and 1 deletions

View File

@ -1050,7 +1050,7 @@ public class NumericArithmetic {
/**
* tanh
*/
@ExecFunction(name = "cosh")
@ExecFunction(name = "tanh")
public static Expression tanh(DoubleLiteral first) {
return checkOutputBoundary(new DoubleLiteral(Math.tanh(first.getValue())));
}

View File

@ -470,6 +470,9 @@ suite("fold_constant_numeric_arithmatic") {
testFoldConst("SELECT TANH(0) AS tanh_case_1") //tanh(0) = 0
testFoldConst("SELECT TANH(1) AS tanh_case_2") //tanh(1)
testFoldConst("SELECT TANH(-1) AS tanh_case_3") //tanh(-1)
testFoldConst("SELECT TANH(NULL)")
testFoldConst("SELECT TANH(-0.5), TANH(0.5), TANH(10), TANH(-10)")
testFoldConst("SELECT TANH(-20), TANH(20), TANH(1E-7), TANH(-1E-7)")
//Truncate function cases
testFoldConst("SELECT TRUNCATE(123.456, 2) AS truncate_case_1") //truncate(123.456, 2) = 123.45