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 d3b4193e968 [fix](nereids)str_to_date function's signature for folding constant is wrong #32474 (#32478) d3b4193e968 is described below commit d3b4193e96891f667c423a1dab02451d8eb9dce0 Author: starocean999 <40539150+starocean...@users.noreply.github.com> AuthorDate: Thu Mar 21 14:09:44 2024 +0800 [fix](nereids)str_to_date function's signature for folding constant is wrong #32474 (#32478) --- .../functions/executable/DateTimeExtractAndTransform.java | 11 ++++++++--- .../partition_prune/test_date_function_prune.groovy | 5 +++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java index 8b51ceeb177..e458b975475 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/executable/DateTimeExtractAndTransform.java @@ -570,10 +570,15 @@ public class DateTimeExtractAndTransform { /** * date transformation function: str_to_date */ - @ExecFunction(name = "str_to_date", argTypes = {"VARCHAR, VARCHAR"}, returnType = "DATETIME") + @ExecFunction(name = "str_to_date", argTypes = {"VARCHAR", "VARCHAR"}, returnType = "DATETIMEV2") public static Expression strToDate(VarcharLiteral str, VarcharLiteral format) { - return DateTimeLiteral.fromJavaDateType(DateUtils.getTime(DateUtils.formatBuilder(format.getValue()) - .toFormatter(), str.getValue())); + if (org.apache.doris.analysis.DateLiteral.hasTimePart(format.getStringValue())) { + return DateTimeV2Literal.fromJavaDateType(DateUtils.getTime(DateUtils.formatBuilder(format.getValue()) + .toFormatter(), str.getValue())); + } else { + return DateV2Literal.fromJavaDateType(DateUtils.getTime(DateUtils.formatBuilder(format.getValue()) + .toFormatter(), str.getValue())); + } } @ExecFunction(name = "timestamp", argTypes = {"DATETIME"}, returnType = "DATETIME") diff --git a/regression-test/suites/nereids_rules_p0/partition_prune/test_date_function_prune.groovy b/regression-test/suites/nereids_rules_p0/partition_prune/test_date_function_prune.groovy index 1523bbb662f..cd2a509fa07 100644 --- a/regression-test/suites/nereids_rules_p0/partition_prune/test_date_function_prune.groovy +++ b/regression-test/suites/nereids_rules_p0/partition_prune/test_date_function_prune.groovy @@ -74,4 +74,9 @@ suite("test_date_function_prune") { sql "select * from dp where Date(date_time) in ('2020-01-01', '2020-01-03')" contains("partitions=2/3 (p1,p3)") } + + explain { + sql "select * from dp where date_time > str_to_date('2020-01-02','%Y-%m-%d')" + contains("partitions=2/3 (p2,p3)") + } } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org