hubgeter commented on code in PR #52954:
URL: https://github.com/apache/doris/pull/52954#discussion_r2195598641
##########
be/src/vec/exec/format/column_type_convert.h:
##########
@@ -592,6 +593,62 @@ class CastStringConverter : public ColumnTypeConverter {
}
};
+template <PrimitiveType DstPrimitiveType>
+class DateTimeToNumericConverter : public ColumnTypeConverter {
+public:
+ Status convert(ColumnPtr& src_col, MutableColumnPtr& dst_col) override {
+ using SrcColumnType = typename
PrimitiveTypeTraits<TYPE_DATETIMEV2>::ColumnType;
+ using DstColumnType = typename
PrimitiveTypeTraits<DstPrimitiveType>::ColumnType;
+ using SrcCppType = typename
PrimitiveTypeTraits<TYPE_DATETIMEV2>::CppType;
+ using DstCppType = typename
PrimitiveTypeTraits<DstPrimitiveType>::CppType;
+
+ ColumnPtr from_col = remove_nullable(src_col);
+ MutableColumnPtr to_col =
remove_nullable(dst_col->get_ptr())->assume_mutable();
+
+ NullMap* null_map = nullptr;
+ if (dst_col->is_nullable()) {
+ null_map =
&reinterpret_cast<vectorized::ColumnNullable*>(dst_col.get())
+ ->get_null_map_data();
+ }
+
+ size_t rows = from_col->size();
+ auto& src_data = static_cast<const
SrcColumnType*>(from_col.get())->get_data();
+ size_t start_idx = to_col->size();
+ to_col->resize(start_idx + rows);
+ auto& data = static_cast<DstColumnType&>(*to_col.get()).get_data();
+
+ for (int i = 0; i < rows; ++i) {
+ const SrcCppType& src_value = src_data[i];
+ auto& dst_value = reinterpret_cast<DstCppType&>(data[start_idx +
i]);
+
+ int64_t ts_s = 0;
+ if (!src_value.unix_timestamp(&ts_s, cctz::utc_time_zone())) {
Review Comment:
No need. Timezone conversion should be handled during the conversion from
the Parquet physical type (int64) to the Parquet logical type (timestamp). Ref
: `struct Int64ToTimestamp : public PhysicalToLogicalConverter`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]