Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
gdliu3 committed Jul 26, 2024
1 parent 7f56fee commit ee5c820
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions be/src/vec/data_types/serde/data_type_datetimev2_serde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,22 @@ void DataTypeDateTimeV2SerDe::write_column_to_arrow(const IColumn& column, const
if (scale > 3) {
uint32_t microsecond = datetime_val.microsecond();
timestamp = (timestamp * 1000000) + microsecond;
timestamp -= std::chrono::duration_cast<std::chrono::microseconds>(cctz::convert(cctz::civil_second(1970, 1, 1, 0, 0, 0), ctz)
.time_since_epoch())
.count();
timestamp -= std::chrono::duration_cast<std::chrono::microseconds>(
cctz::convert(cctz::civil_second(1970, 1, 1, 0, 0, 0), ctz)
.time_since_epoch())
.count();
} else if (scale > 0) {
uint32_t millisecond = datetime_val.microsecond() / 1000;
timestamp = (timestamp * 1000) + millisecond;
timestamp -= std::chrono::duration_cast<std::chrono::milliseconds>(cctz::convert(cctz::civil_second(1970, 1, 1, 0, 0, 0), ctz)
.time_since_epoch())
.count();
} else if (scale == 0){
timestamp -= std::chrono::duration_cast<std::chrono::seconds>(cctz::convert(cctz::civil_second(1970, 1, 1, 0, 0, 0), ctz)
.time_since_epoch())
.count();
timestamp -= std::chrono::duration_cast<std::chrono::milliseconds>(
cctz::convert(cctz::civil_second(1970, 1, 1, 0, 0, 0), ctz)
.time_since_epoch())
.count();
} else if (scale == 0) {
timestamp -= std::chrono::duration_cast<std::chrono::seconds>(
cctz::convert(cctz::civil_second(1970, 1, 1, 0, 0, 0), ctz)
.time_since_epoch())
.count();
}

checkArrowStatus(timestamp_builder.Append(timestamp), column.get_name(),
Expand Down

0 comments on commit ee5c820

Please sign in to comment.