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 ebc178af23c [fix](nereids)acos function should return null literal instead of NaN value (#37996) ebc178af23c is described below commit ebc178af23cf6d0b3d46156c290a60bfd74c2521 Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Thu Jul 18 09:28:56 2024 +0800 [fix](nereids)acos function should return null literal instead of NaN value (#37996) pick from master https://github.com/apache/doris/pull/37932 ## Proposed changes Issue Number: close #xxx <!--Describe your changes.--> --- .../functions/executable/ExecutableFunctions.java | 12 +++++++++- .../data/nereids_function_p0/scalar_function/A.out | 26 +++++++++++++--------- .../nereids_function_p0/scalar_function/A.groovy | 2 ++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java index 2e84542fd04..42ad228ad72 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/ExecutableFunctions.java @@ -26,10 +26,12 @@ import org.apache.doris.nereids.trees.expressions.literal.DoubleLiteral; import org.apache.doris.nereids.trees.expressions.literal.FloatLiteral; import org.apache.doris.nereids.trees.expressions.literal.IntegerLiteral; import org.apache.doris.nereids.trees.expressions.literal.LargeIntLiteral; +import org.apache.doris.nereids.trees.expressions.literal.NullLiteral; import org.apache.doris.nereids.trees.expressions.literal.SmallIntLiteral; import org.apache.doris.nereids.trees.expressions.literal.StringLikeLiteral; import org.apache.doris.nereids.trees.expressions.literal.TinyIntLiteral; import org.apache.doris.nereids.trees.expressions.literal.VarcharLiteral; +import org.apache.doris.nereids.types.DoubleType; import java.math.BigInteger; import java.security.SecureRandom; @@ -90,9 +92,17 @@ public class ExecutableFunctions { return new DecimalV3Literal(literal.getValue().abs()); } + /** + * acos scalar function + */ @ExecFunction(name = "acos", argTypes = {"DOUBLE"}, returnType = "DOUBLE") public static Expression acos(DoubleLiteral literal) { - return new DoubleLiteral(Math.acos(literal.getValue())); + double result = Math.acos(literal.getValue()); + if (Double.isNaN(result)) { + return new NullLiteral(DoubleType.INSTANCE); + } else { + return new DoubleLiteral(result); + } } @ExecFunction(name = "append_trailing_char_if_absent", argTypes = {"VARCHAR", "VARCHAR"}, returnType = "VARCHAR") diff --git a/regression-test/data/nereids_function_p0/scalar_function/A.out b/regression-test/data/nereids_function_p0/scalar_function/A.out index f2330c11375..20ad9d7fd19 100644 --- a/regression-test/data/nereids_function_p0/scalar_function/A.out +++ b/regression-test/data/nereids_function_p0/scalar_function/A.out @@ -260,6 +260,12 @@ \N \N +-- !sql_acos_Double_NAN -- +\N + +-- !sql_acos_Double_NULL -- +\N + -- !sql_append_trailing_char_if_absent_Varchar_Varchar -- \N \N @@ -437,29 +443,29 @@ -- !sql_atan2_Double -- \N 1.4711276743037345 -1.3734007669450159 +1.373400766945016 1.2793395323170296 1.1902899496825317 1.1071487177940904 1.0303768265243125 0.960070362405688 -0.89605538457134393 +0.8960553845713439 0.83798122500839 -0.78539816339744828 -0.73781506012046483 -0.69473827619670314 +0.7853981633974483 +0.7378150601204648 +0.6947382761967031 -- !sql_atan2_Double_notnull -- 1.4711276743037345 -1.3734007669450159 +1.373400766945016 1.2793395323170296 1.1902899496825317 1.1071487177940904 1.0303768265243125 0.960070362405688 -0.89605538457134393 +0.8960553845713439 0.83798122500839 -0.78539816339744828 -0.73781506012046483 -0.69473827619670314 +0.7853981633974483 +0.7378150601204648 +0.6947382761967031 diff --git a/regression-test/suites/nereids_function_p0/scalar_function/A.groovy b/regression-test/suites/nereids_function_p0/scalar_function/A.groovy index 6938f916e0d..4ae51024d34 100644 --- a/regression-test/suites/nereids_function_p0/scalar_function/A.groovy +++ b/regression-test/suites/nereids_function_p0/scalar_function/A.groovy @@ -37,6 +37,8 @@ suite("nereids_scalar_fn_A") { qt_sql_abs_DecimalV2_notnull "select abs(kdcmls1) from fn_test_not_nullable order by kdcmls1" qt_sql_acos_Double "select acos(kdbl) from fn_test order by kdbl" qt_sql_acos_Double_notnull "select acos(kdbl) from fn_test_not_nullable order by kdbl" + qt_sql_acos_Double_NAN "select acos(cast(1.1 as double))" + qt_sql_acos_Double_NULL "select acos(null)" sql "select aes_decrypt(kvchrs1, kvchrs1) from fn_test order by kvchrs1, kvchrs1" sql "select aes_decrypt(kvchrs1, kvchrs1) from fn_test_not_nullable order by kvchrs1, kvchrs1" sql "select aes_decrypt(kstr, kstr) from fn_test order by kstr, kstr" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org