This is an automated email from the ASF dual-hosted git repository. morrysnow 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 f2354a69869 [Fix](nereids) fix date function rewrite (#32130) f2354a69869 is described below commit f2354a6986917fb23cb7036a6cf761cc154523f6 Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com> AuthorDate: Wed Mar 13 10:23:13 2024 +0800 [Fix](nereids) fix date function rewrite (#32130) pick to 2.0 #32060 Co-authored-by: feiniaofeiafei <moail...@selectdb.com> --- .../expression/rules/DateFunctionRewrite.java | 4 +-- .../date_function_rewrite.out | 4 +++ .../date_function_rewrite.groovy | 30 ++++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java index e80022b0ba9..e78eeecff0d 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/rules/expression/rules/DateFunctionRewrite.java @@ -77,14 +77,14 @@ public class DateFunctionRewrite extends AbstractExpressionRewriteRule { if (greaterThan.left().child(0).getDataType() instanceof DateTimeType && greaterThan.right() instanceof DateLiteral) { DateTimeLiteral newLiteral = ((DateLiteral) greaterThan.right()).toBeginOfTomorrow(); - return new GreaterThan(greaterThan.left().child(0), newLiteral); + return new GreaterThanEqual(greaterThan.left().child(0), newLiteral); } // V2 if (greaterThan.left().child(0).getDataType() instanceof DateTimeV2Type && greaterThan.right() instanceof DateV2Literal) { DateTimeV2Literal newLiteral = ((DateV2Literal) greaterThan.right()).toBeginOfTomorrow(); - return new GreaterThan(greaterThan.left().child(0), newLiteral); + return new GreaterThanEqual(greaterThan.left().child(0), newLiteral); } } diff --git a/regression-test/data/nereids_rules_p0/date_function_rewrite/date_function_rewrite.out b/regression-test/data/nereids_rules_p0/date_function_rewrite/date_function_rewrite.out new file mode 100644 index 00000000000..2ef8304a2a0 --- /dev/null +++ b/regression-test/data/nereids_rules_p0/date_function_rewrite/date_function_rewrite.out @@ -0,0 +1,4 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !test -- +1 + diff --git a/regression-test/suites/nereids_rules_p0/date_function_rewrite/date_function_rewrite.groovy b/regression-test/suites/nereids_rules_p0/date_function_rewrite/date_function_rewrite.groovy new file mode 100644 index 00000000000..01afc01431a --- /dev/null +++ b/regression-test/suites/nereids_rules_p0/date_function_rewrite/date_function_rewrite.groovy @@ -0,0 +1,30 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("date_function_rewrite") { + sql "SET enable_nereids_planner=true" + sql "SET enable_fallback_to_original_planner=false" + sql "drop table if exists test_date_func" + sql """ + create table test_date_func(a int, test_time int(11)) distributed by hash (a) buckets 5 + properties("replication_num"="1"); + """ + sql "insert into test_date_func values(1,1690128000);\n" + qt_test """ + select if (date(date_add(FROM_UNIXTIME(t1.test_time, '%Y-%m-%d'),2)) > '2023-07-25',1,0) from test_date_func t1; + """ +} \ 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