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

yiguolei pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new 460ff02997d [cherry-pick](branch-21)fix date_floor function return 
wrong result (#41948) (#42065)
460ff02997d is described below

commit 460ff02997d839870e7a879f627263d0be35d000
Author: zhangstar333 <[email protected]>
AuthorDate: Fri Oct 18 21:54:22 2024 +0800

    [cherry-pick](branch-21)fix date_floor function return wrong result 
(#41948) (#42065)
    
    ## Proposed changes
    
    cherry-pick from master https://github.com/apache/doris/pull/41948
    
    <!--Describe your changes.-->
---
 be/src/vec/functions/function_datetime_floor_ceil.cpp        | 9 ++++++---
 regression-test/data/correctness_p0/test_time_round.out      | 5 +++++
 regression-test/suites/correctness_p0/test_time_round.groovy | 1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/be/src/vec/functions/function_datetime_floor_ceil.cpp 
b/be/src/vec/functions/function_datetime_floor_ceil.cpp
index 6cdfd01083d..75cfd4e485f 100644
--- a/be/src/vec/functions/function_datetime_floor_ceil.cpp
+++ b/be/src/vec/functions/function_datetime_floor_ceil.cpp
@@ -21,6 +21,9 @@
 
 #include <algorithm>
 #include <boost/iterator/iterator_facade.hpp>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
 #include <memory>
 #include <type_traits>
 #include <utility>
@@ -284,7 +287,7 @@ struct FloorCeilImpl {
                                       PaddedPODArray<NativeType>& res, 
NullMap& null_map) {
         // time_round(datetime,const(period))
         if (period < 1) {
-            null_map.resize_fill(dates.size(), true);
+            memset(null_map.data(), 1, sizeof(UInt8) * dates.size());
             return;
         }
         for (int i = 0; i < dates.size(); ++i) {
@@ -325,7 +328,7 @@ struct FloorCeilImpl {
                                    NativeType origin_date, 
PaddedPODArray<NativeType>& res,
                                    NullMap& null_map) {
         if (period < 1) {
-            null_map.resize_fill(dates.size(), true);
+            memset(null_map.data(), 1, sizeof(UInt8) * dates.size());
             return;
         }
         switch (period) {
@@ -410,7 +413,7 @@ struct FloorCeilImpl {
                                     const PaddedPODArray<NativeType>& 
origin_dates,
                                     PaddedPODArray<NativeType>& res, NullMap& 
null_map) {
         if (period < 1) {
-            null_map.resize_fill(dates.size(), true);
+            memset(null_map.data(), 1, sizeof(UInt8) * dates.size());
             return;
         }
         for (int i = 0; i < dates.size(); ++i) {
diff --git a/regression-test/data/correctness_p0/test_time_round.out 
b/regression-test/data/correctness_p0/test_time_round.out
index face63a18a9..41e268482ed 100644
--- a/regression-test/data/correctness_p0/test_time_round.out
+++ b/regression-test/data/correctness_p0/test_time_round.out
@@ -123,3 +123,8 @@
 2020-02-02T11:45:14
 2020-02-02T11:45:14
 
+-- !select_1 --
+2020-02-02T13:09:20    \N
+2020-02-02T13:09:20    \N
+2020-02-02T13:09:20    \N
+
diff --git a/regression-test/suites/correctness_p0/test_time_round.groovy 
b/regression-test/suites/correctness_p0/test_time_round.groovy
index c042e0dd935..4ab6a6f6473 100644
--- a/regression-test/suites/correctness_p0/test_time_round.groovy
+++ b/regression-test/suites/correctness_p0/test_time_round.groovy
@@ -89,4 +89,5 @@ suite("test_time_round") {
     qt_select "select hour_floor(dt,2,o) from dbround order by id;"
     qt_select "select hour_floor(dt,p,'1919-08-10 11:45:14') from dbround 
order by id;"
     qt_select "select hour_floor(dt,2,'1919-08-10 11:45:14') from dbround 
order by id;"
+    qt_select_1 "select dt,hour_floor(dt,0) from dbround order by id;"
 }


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

Reply via email to