This is an automated email from the ASF dual-hosted git repository. lide 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 6d9492da62c [fix](planner) fix result wrong caused by mixed use multiple columns with type of datetime/datetimev2/date/datev2 of function coalesce (#36640) 6d9492da62c is described below commit 6d9492da62ca0dce2043312d439faf62503c7db8 Author: Yulei-Yang <yulei.yang0...@gmail.com> AuthorDate: Fri Jun 21 16:21:45 2024 +0800 [fix](planner) fix result wrong caused by mixed use multiple columns with type of datetime/datetimev2/date/datev2 of function coalesce (#36640) --- .../org/apache/doris/analysis/FunctionCallExpr.java | 8 ++++++++ .../conditional_functions/test_coalesce_new.groovy | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) 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 1a52c965818..3f92c959670 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 @@ -1557,6 +1557,14 @@ public class FunctionCallExpr extends Expr { argTypes[i] = assignmentCompatibleType; } } + } else if (assignmentCompatibleType.isDateV2OrDateTimeV2()) { + for (int i = 0; i < childTypes.length; i++) { + if (assignmentCompatibleType.isDateV2OrDateTimeV2() + && !childTypes[i].equals(assignmentCompatibleType)) { + uncheckedCastChild(assignmentCompatibleType, i); + argTypes[i] = assignmentCompatibleType; + } + } } fn = getBuiltinFunction(fnName.getFunction(), argTypes, Function.CompareMode.IS_NONSTRICT_SUPERTYPE_OF); diff --git a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_coalesce_new.groovy b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_coalesce_new.groovy index 194849a3c63..a223c5d4cbd 100644 --- a/regression-test/suites/query_p0/sql_functions/conditional_functions/test_coalesce_new.groovy +++ b/regression-test/suites/query_p0/sql_functions/conditional_functions/test_coalesce_new.groovy @@ -51,6 +51,14 @@ suite("test_coalesce_new") { select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01' """ assertEquals(result1.size(), 2); + def result11 = try_sql """ + select dt from test_cls where coalesce (dt, dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01' + """ + assertEquals(result11.size(), 2); + def result12 = try_sql """ + select dt from test_cls where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d'), str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01' + """ + assertEquals(result12.size(), 2); // test parameter:datetimev2, datev2 @@ -88,6 +96,15 @@ suite("test_coalesce_new") { select dt from test_cls_dtv2 where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01' """ assertEquals(result2.size(), 2); + def result21 = try_sql """ + select dt from test_cls_dtv2 where coalesce (dt, dt, str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01' + """ + assertEquals(result21.size(), 2); + def result22 = try_sql """ + select dt from test_cls_dtv2 where coalesce (dt, str_to_date(concat('202306', '01'), '%Y%m%d'), str_to_date(concat('202306', '01'), '%Y%m%d')) >= '2023-06-01' + """ + assertEquals(result22.size(), 2); + sql """ drop table test_cls @@ -98,4 +115,7 @@ suite("test_coalesce_new") { sql """ admin set frontend config ("disable_datev1"="false") """ + sql """ + admin set frontend config ("enable_date_conversion"="true") + """ } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org