This is an automated email from the ASF dual-hosted git repository.
kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 55d34a729c1 [fix](planner) fix ifnull and nvl function with one
parameters exception message anbugious (#31808) (#31847)
55d34a729c1 is described below
commit 55d34a729c1c67574c9644edc3ec9d0b4780df99
Author: LiBinfeng <[email protected]>
AuthorDate: Thu Mar 7 11:38:10 2024 +0800
[fix](planner) fix ifnull and nvl function with one parameters exception
message anbugious (#31808) (#31847)
---
.../java/org/apache/doris/analysis/FunctionCallExpr.java | 2 ++
.../suites/nereids_function_p0/scalar_function/N.groovy | 16 +++++++++++++++-
.../conditional_functions/test_ifnull.groovy | 9 +++++++++
.../sql_functions/conditional_functions/test_nvl.groovy | 8 ++++++++
4 files changed, 34 insertions(+), 1 deletion(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
index a15c345014c..b7bc0cea969 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/FunctionCallExpr.java
@@ -1517,6 +1517,8 @@ public class FunctionCallExpr extends Expr {
} else if (fnName.getFunction().equalsIgnoreCase("ifnull")
|| fnName.getFunction().equalsIgnoreCase("nvl")) {
+ Preconditions.checkArgument(children != null && children.size() ==
2,
+ "The " + fnName + " function must have two params");
Type[] childTypes = collectChildReturnTypes();
Type assignmentCompatibleType =
ScalarType.getAssignmentCompatibleType(childTypes[0], childTypes[1], true);
if (assignmentCompatibleType != Type.INVALID) {
diff --git
a/regression-test/suites/nereids_function_p0/scalar_function/N.groovy
b/regression-test/suites/nereids_function_p0/scalar_function/N.groovy
index 7b399e3aae8..c99372058ec 100644
--- a/regression-test/suites/nereids_function_p0/scalar_function/N.groovy
+++ b/regression-test/suites/nereids_function_p0/scalar_function/N.groovy
@@ -103,4 +103,18 @@ suite("nereids_scalar_fn_N") {
qt_sql_nvl_Varchar_Varchar_notnull "select nvl(kvchrs1, kvchrs1) from
fn_test_not_nullable order by kvchrs1, kvchrs1"
qt_sql_nvl_String_String "select nvl(kstr, kstr) from fn_test order by
kstr, kstr"
qt_sql_nvl_String_String_notnull "select nvl(kstr, kstr) from
fn_test_not_nullable order by kstr, kstr"
-}
\ No newline at end of file
+ test{
+ sql"""select ifnull(kstr) from fn_test"""
+ check {result, exception, startTime, endTime ->
+ assertTrue(exception != null)
+ logger.info(exception.message)
+ }
+ }
+ test{
+ sql"""select nvl(kstr) from fn_test"""
+ check {result, exception, startTime, endTime ->
+ assertTrue(exception != null)
+ logger.info(exception.message)
+ }
+ }
+}
diff --git
a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_ifnull.groovy
b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_ifnull.groovy
index 32ccc70ebc4..f1f0528d54d 100644
---
a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_ifnull.groovy
+++
b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_ifnull.groovy
@@ -17,6 +17,7 @@
suite("test_ifnull") {
def tbName = "test_ifnull"
+ sql "set enable_nereids_planner=false"
sql "DROP TABLE IF EXISTS ${tbName};"
sql"""
CREATE TABLE IF NOT EXISTS ${tbName} (
@@ -35,6 +36,14 @@ suite("test_ifnull") {
qt_sql "select id,t_decimal,test_double,ifnull(t_decimal,test_double)
as if_dou,ifnull(test_double,t_decimal) as if_dei from test_ifnull;"
+ test{
+ sql"""select ifnull(kstr) from fn_test"""
+ check {result, exception, startTime, endTime ->
+ assertTrue(exception != null)
+ logger.info(exception.message)
+ }
+ }
+
sql "DROP TABLE ${tbName};"
}
diff --git
a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nvl.groovy
b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nvl.groovy
index 5c19602b6c1..7a9e9f28a29 100644
---
a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nvl.groovy
+++
b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_nvl.groovy
@@ -19,4 +19,12 @@ suite("test_nvl") {
qt_select "select nvl(k6, \"false\") k from test_query_db.test order by k1"
sql """set enable_nereids_planner=false;"""
qt_select2 "select nvl(123456.134444454,0);"
+
+ test{
+ sql"""select nvl(k6) from test_query_db.test"""
+ check {result, exception, startTime, endTime ->
+ assertTrue(exception != null)
+ logger.info(exception.message)
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]