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 87d468e commit 7f56fee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
6 changes: 3 additions & 3 deletions be/src/util/arrow/row_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ Status convert_to_arrow_type(const TypeDescriptor& type, std::shared_ptr<arrow::
break;
case TYPE_DATETIMEV2:
if (type.scale > 3) {
*result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MICRO);
*result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MICRO, "UTC");
} else if (type.scale > 0) {
*result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MILLI);
*result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::MILLI, "UTC");
} else {
*result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::SECOND);
*result = std::make_shared<arrow::TimestampType>(arrow::TimeUnit::SECOND, "UTC");
}
break;
case TYPE_DECIMALV2:
Expand Down
23 changes: 10 additions & 13 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,22 +117,19 @@ 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 7f56fee

Please sign in to comment.