This is an automated email from the ASF dual-hosted git repository. lihaopeng 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 07fe7c0f284 [bug](function)fix date_floor function return wrong result (#41948) 07fe7c0f284 is described below commit 07fe7c0f284d0289797573eb53361b970e74d98d Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com> AuthorDate: Thu Oct 17 20:16:02 2024 +0800 [bug](function)fix date_floor function return wrong result (#41948) ``` void resize_fill(size_t n, const T& value) { size_t old_size = this->size(); if (n > old_size) { this->reserve(n); std::fill(t_end(), t_end() + n - old_size, value); } this->c_end = this->c_start + this->byte_size(n); } ``` if n is not greater than old_size, it's will not fill the data with value. so it's not set the null_map flag to 1, it's can't return NULL ``` mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6; +---------------------+--------------------+ | k11 | hour_floor(k11, 0) | +---------------------+--------------------+ | 2015-03-13 12:36:38 | | +---------------------+--------------------+ 1 row in set (0.03 se ``` after fix: ``` mysql [test_query_qa]>select k11,hour_floor(k11,0) from baseall where k1 = 6; +---------------------+--------------------+ | k11 | hour_floor(k11, 0) | +---------------------+--------------------+ | 2015-03-13 12:36:38 | NULL | +---------------------+--------------------+ 1 row in set (0.03 sec) ``` --- be/src/vec/functions/function_datetime_floor_ceil.cpp | 7 ++++--- regression-test/data/correctness_p0/test_time_round.out | 5 +++++ regression-test/suites/correctness_p0/test_time_round.groovy | 1 + 3 files changed, 10 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 4801c4aa53b..bf74deaed1d 100644 --- a/be/src/vec/functions/function_datetime_floor_ceil.cpp +++ b/be/src/vec/functions/function_datetime_floor_ceil.cpp @@ -21,6 +21,7 @@ #include <boost/iterator/iterator_facade.hpp> #include <cstddef> #include <cstdint> +#include <cstring> #include <memory> #include <type_traits> #include <utility> @@ -293,7 +294,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) { @@ -337,7 +338,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) { @@ -424,7 +425,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: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org