Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cherry-pick](branch-21)fix date_floor function return wrong result (#41948) #42065

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions be/src/vec/functions/function_datetime_floor_ceil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
5 changes: 5 additions & 0 deletions regression-test/data/correctness_p0/test_time_round.out
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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;"
}
Loading