This is an automated email from the ASF dual-hosted git repository. yangzhg pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push: new 45a8ceed2e [bugfix](datetimev2) fix coredump when load datatime data to doris (#15510) 45a8ceed2e is described below commit 45a8ceed2ec270338151be53c9aa74a389608d70 Author: Zhengguo Yang <yangz...@gmail.com> AuthorDate: Tue Jan 3 10:05:44 2023 +0800 [bugfix](datetimev2) fix coredump when load datatime data to doris (#15510) --- be/src/runtime/types.h | 2 ++ be/src/vec/data_types/data_type_decimal.h | 3 +-- be/src/vec/data_types/data_type_time_v2.cpp | 4 ++-- be/src/vec/data_types/data_type_time_v2.h | 8 ++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/be/src/runtime/types.h b/be/src/runtime/types.h index 4f4c2ef0fe..06629a655e 100644 --- a/be/src/runtime/types.h +++ b/be/src/runtime/types.h @@ -73,6 +73,8 @@ struct TypeDescriptor { if (type == TYPE_DECIMALV2) { precision = 27; scale = 9; + } else if (type == TYPE_DATETIMEV2) { + scale = 6; } } diff --git a/be/src/vec/data_types/data_type_decimal.h b/be/src/vec/data_types/data_type_decimal.h index c8e08303a1..ef3d58758a 100644 --- a/be/src/vec/data_types/data_type_decimal.h +++ b/be/src/vec/data_types/data_type_decimal.h @@ -118,8 +118,7 @@ public: static constexpr size_t max_precision() { return max_decimal_precision<T>(); } - DataTypeDecimal(UInt32 precision_ = 27, UInt32 scale_ = 9) - : precision(precision_), scale(scale_) { + DataTypeDecimal(UInt32 precision = 27, UInt32 scale = 9) : precision(precision), scale(scale) { if (UNLIKELY(precision < 1 || precision > max_precision())) { LOG(FATAL) << fmt::format("Precision {} is out of bounds", precision); } diff --git a/be/src/vec/data_types/data_type_time_v2.cpp b/be/src/vec/data_types/data_type_time_v2.cpp index a42c9be4aa..ed52721ee7 100644 --- a/be/src/vec/data_types/data_type_time_v2.cpp +++ b/be/src/vec/data_types/data_type_time_v2.cpp @@ -92,7 +92,7 @@ std::string DataTypeDateTimeV2::to_string(const IColumn& column, size_t row_num) binary_cast<UInt64, DateV2Value<DateTimeV2ValueType>>(int_val); char buf[64]; - char* pos = val.to_string(buf, scale_); + char* pos = val.to_string(buf, _scale); return std::string(buf, pos - buf - 1); } @@ -105,7 +105,7 @@ void DataTypeDateTimeV2::to_string(const IColumn& column, size_t row_num, binary_cast<UInt64, DateV2Value<DateTimeV2ValueType>>(int_val); char buf[64]; - char* pos = value.to_string(buf, scale_); + char* pos = value.to_string(buf, _scale); // DateTime to_string the end is /0 ostr.write(buf, pos - buf - 1); } diff --git a/be/src/vec/data_types/data_type_time_v2.h b/be/src/vec/data_types/data_type_time_v2.h index f65768a45c..75c8c9b142 100644 --- a/be/src/vec/data_types/data_type_time_v2.h +++ b/be/src/vec/data_types/data_type_time_v2.h @@ -57,13 +57,13 @@ class DataTypeDateTimeV2 final : public DataTypeNumberBase<UInt64> { public: static constexpr bool is_parametric = true; - DataTypeDateTimeV2(UInt32 scale = 0) : scale_(scale) { + DataTypeDateTimeV2(UInt32 scale = 0) : _scale(scale) { if (UNLIKELY(scale > 6)) { LOG(FATAL) << fmt::format("Scale {} is out of bounds", scale); } } - DataTypeDateTimeV2(const DataTypeDateTimeV2& rhs) : scale_(rhs.scale_) {} + DataTypeDateTimeV2(const DataTypeDateTimeV2& rhs) : _scale(rhs._scale) {} TypeIndex get_type_id() const override { return TypeIndex::DateTimeV2; } const char* get_family_name() const override { return "DateTimeV2"; } std::string do_get_name() const override { return "DateTimeV2"; } @@ -77,7 +77,7 @@ public: MutableColumnPtr create_column() const override; - const UInt32 get_scale() const { return scale_; } + const UInt32 get_scale() const { return _scale; } static void cast_to_date(const UInt64 from, Int64& to); static void cast_to_date_time(const UInt64 from, Int64& to); @@ -86,7 +86,7 @@ public: static void cast_from_date_time(const Int64 from, UInt64& to); private: - UInt32 scale_; + UInt32 _scale; }; template <typename DataType> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org