Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
gdliu3 committed Jul 24, 2024
1 parent 03499b8 commit e15b12e
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 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,15 +117,24 @@ 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();
} 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::seconds>(
cctz::convert(cctz::civil_second(1970, 1, 1, 0, 0, 0), ctz)
.time_since_epoch())
.count() *
1000000;

checkArrowStatus(timestamp_builder.Append(timestamp), column.get_name(),
array_builder->type()->name());
}
Expand Down

0 comments on commit e15b12e

Please sign in to comment.