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

commit 0d52ee34d654160e7592e4b3f9f105032b25ac5a
Author: Mryange <[email protected]>
AuthorDate: Thu Aug 17 15:34:26 2023 +0800

    [fix](executor)fix no return with old type in time_round
---
 .../vec/functions/function_datetime_floor_ceil.cpp |  3 ++
 be/src/vec/runtime/vdatetime_value.cpp             |  1 -
 be/src/vec/runtime/vdatetime_value.h               |  3 ++
 .../data/correctness_p0/test_time_round.out        | 41 ++++++++++++++++++++++
 .../suites/correctness_p0/test_time_round.groovy   | 29 +++++++++++++++
 5 files changed, 76 insertions(+), 1 deletion(-)

diff --git a/be/src/vec/functions/function_datetime_floor_ceil.cpp 
b/be/src/vec/functions/function_datetime_floor_ceil.cpp
index 0e4518f2d0..80b5b6b96d 100644
--- a/be/src/vec/functions/function_datetime_floor_ceil.cpp
+++ b/be/src/vec/functions/function_datetime_floor_ceil.cpp
@@ -522,6 +522,9 @@ struct TimeRound {
             is_null = false;
             return;
         };
+        if constexpr (std::is_same_v<DateValueType, VecDateTimeValue>) {
+            ts1.reset_zero_by_type(ts2.type());
+        }
         int64_t diff;
         int64_t part;
         if constexpr (Impl::Unit == YEAR) {
diff --git a/be/src/vec/runtime/vdatetime_value.cpp 
b/be/src/vec/runtime/vdatetime_value.cpp
index e23cad1e2b..f701e96f30 100644
--- a/be/src/vec/runtime/vdatetime_value.cpp
+++ b/be/src/vec/runtime/vdatetime_value.cpp
@@ -1678,7 +1678,6 @@ bool VecDateTimeValue::date_set_interval(const 
TimeInterval& interval) {
                     (unit == MINUTE) || (unit == SECOND),
             "date_set_interval function now only support YEAR MONTH DAY HOUR 
MINUTE SECOND type");
     if constexpr ((unit == SECOND) || (unit == MINUTE) || (unit == HOUR)) {
-        set_zero(type());
         // This may change the day information
         int64_t seconds = interval.day * 86400L + interval.hour * 3600 + 
interval.minute * 60 +
                           interval.second;
diff --git a/be/src/vec/runtime/vdatetime_value.h 
b/be/src/vec/runtime/vdatetime_value.h
index d71b78dbe2..fa3638fb94 100644
--- a/be/src/vec/runtime/vdatetime_value.h
+++ b/be/src/vec/runtime/vdatetime_value.h
@@ -665,6 +665,9 @@ public:
 
     bool get_date_from_daynr(uint64_t);
 
+    // reset 0
+    void reset_zero_by_type(int type) { set_zero(type); }
+
 private:
     // Used to make sure sizeof VecDateTimeValue
     friend class UnusedClass;
diff --git a/regression-test/data/correctness_p0/test_time_round.out 
b/regression-test/data/correctness_p0/test_time_round.out
index 9e902554bb..a5d5acecd8 100644
--- a/regression-test/data/correctness_p0/test_time_round.out
+++ b/regression-test/data/correctness_p0/test_time_round.out
@@ -41,3 +41,44 @@
 -- !select --
 2022-01-01T00:00
 
+-- !select --
+1970-01-01T01:00:30
+
+-- !select --
+1970-01-01T00:00:30
+
+-- !select --
+2022-05-25T00:00
+
+-- !select --
+2022-05-01T00:00
+
+-- !select --
+2022-05-25T00:06
+
+-- !select --
+2022-05-25T00:05
+
+-- !select --
+2022-05-26T00:00
+
+-- !select --
+2022-05-23T00:00
+
+-- !select --
+2022-05-29T00:00
+
+-- !select --
+2022-05-22T00:00
+
+-- !select --
+2022-06-01T00:00
+
+-- !select --
+2022-05-01T00:00
+
+-- !select --
+2023-01-01T00:00
+
+-- !select --
+2022-01-01T00:00
diff --git a/regression-test/suites/correctness_p0/test_time_round.groovy 
b/regression-test/suites/correctness_p0/test_time_round.groovy
index 1fa0426c0d..e60e33ca6e 100644
--- a/regression-test/suites/correctness_p0/test_time_round.groovy
+++ b/regression-test/suites/correctness_p0/test_time_round.groovy
@@ -17,6 +17,8 @@
 
 
 suite("test_time_round") {
+
+    sql """ set enable_nereids_planner=true , 
enable_fallback_to_original_planner=false;"""
     // fix by issues/9711, expect: '1970-01-01T01:00:30'
     qt_select "select hour_ceil('1970-01-01 01:00:10', 1, '1970-01-01 
00:00:30')"
 
@@ -40,4 +42,31 @@ suite("test_time_round") {
     qt_select "select year_ceil('2022-05-25 00:00:00')"
     qt_select "select year_floor('2022-05-25 00:00:00')"
 
+
+    sql """ set enable_nereids_planner=false; """ 
+
+        // fix by issues/9711, expect: '1970-01-01T01:00:30'
+    qt_select "select hour_ceil('1970-01-01 01:00:10', 1, '1970-01-01 
00:00:30')"
+
+    // fix by issues/9711, expect: '1970-01-01T00:00:30'
+    qt_select "select hour_floor('1970-01-01 01:00:10', 1, '1970-01-01 
00:00:30')"
+
+    // fix by issues/9711, expect: '2022-05-25'
+    qt_select "select day_ceil('2022-05-25')"
+
+    // fix by issues/9711, expect: '2022-05-01'
+    qt_select "select month_ceil('2022-05-01')"
+
+    qt_select "select minute_ceil('2022-05-25 00:05:10')"
+    qt_select "select minute_floor('2022-05-25 00:05:10')"
+    qt_select "select day_ceil('2022-05-25 02:00:00', 3, '2022-05-20 
00:00:00')"
+    qt_select "select day_floor('2022-05-25 02:00:00', 3, '2022-05-20 
00:00:00')"
+    qt_select "select week_ceil('2022-05-25 00:00:00')"
+    qt_select "select week_floor('2022-05-25 00:00:00')"
+    qt_select "select month_ceil('2022-05-25 00:00:00')"
+    qt_select "select month_floor('2022-05-25 00:00:00')"
+    qt_select "select year_ceil('2022-05-25 00:00:00')"
+    qt_select "select year_floor('2022-05-25 00:00:00')"
+
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to