This is an automated email from the ASF dual-hosted git repository.

starocean999 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new cd59bdcc1ac [Fix](nereids) fix date function rewrite (#32060)
cd59bdcc1ac is described below

commit cd59bdcc1ac019d3cc44080aa11815669fdc45fd
Author: feiniaofeiafei <53502832+feiniaofeia...@users.noreply.github.com>
AuthorDate: Tue Mar 12 17:49:49 2024 +0800

    [Fix](nereids) fix date function rewrite (#32060)
---
 .../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

Reply via email to