Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
gdliu3 committed Jul 22, 2024
1 parent ba0eb23 commit 9e9ede2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions be/src/vec/data_types/serde/data_type_datetimev2_serde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,16 @@ void DataTypeDateTimeV2SerDe::write_column_to_arrow(const IColumn& column, const
binary_cast<UInt64, DateV2Value<DateTimeV2ValueType>>(col_data[i]);
datetime_val.unix_timestamp(&timestamp, ctz);

uint32_t microsecond = datetime_val.microsecond();

if (scale > 3) {
uint32_t microsecond = datetime_val.microsecond();
timestamp = (timestamp * 1000000) + microsecond;
} else if (scale > 0) {
uint32_t millisecond = datetime_val.microsecond() / 1000;
uint32_t millisecond = microsecond / 1000;

timestamp = (timestamp * 1000) + millisecond;
} else if (scale == 0) { // 对于 datetime
timestamp = timestamp * 1000000; // 转换为微秒级时间戳
}
checkArrowStatus(timestamp_builder.Append(timestamp), column.get_name(),
array_builder->type()->name());
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/runtime/vdatetime_value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3267,7 +3267,7 @@ bool DateV2Value<T>::unix_timestamp(int64_t* timestamp, const cctz::time_zone& c
date_v2_value_.day_, date_v2_value_.hour_,
date_v2_value_.minute_, date_v2_value_.second_),
ctz);
*timestamp = tp.time_since_epoch().count();
*timestamp = std::chrono::duration_cast<std::chrono::seconds>(tp.time_since_epoch()).count();
return true;
} else {
const auto tp =
Expand Down

0 comments on commit 9e9ede2

Please sign in to comment.