This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 80c12bc569b [refactor](type) Remove CppNativeType (#59976)
80c12bc569b is described below

commit 80c12bc569b07d914e3a4c11602d083b3eeda770
Author: Gabriel <[email protected]>
AuthorDate: Sun Jan 18 11:00:18 2026 +0800

    [refactor](type) Remove CppNativeType (#59976)
    
    ### What problem does this PR solve?
    
    Issue Number: close #xxx
    
    Related PR: #xxx
    
    Problem Summary:
    
    ### Release note
    
    None
    
    ### Check List (For Author)
    
    - Test <!-- At least one of them must be included. -->
        - [ ] Regression test
        - [ ] Unit Test
        - [ ] Manual test (add detailed scripts or steps below)
        - [ ] No need to test or manual test. Explain why:
    - [ ] This is a refactor/code format and no logic has been changed.
            - [ ] Previous test can cover this change.
            - [ ] No code files have been changed.
            - [ ] Other reason <!-- Add your reason?  -->
    
    - Behavior changed:
        - [ ] No.
        - [ ] Yes. <!-- Explain the behavior change -->
    
    - Does this need documentation?
        - [ ] No.
    - [ ] Yes. <!-- Add document PR link here. eg:
    https://github.com/apache/doris-website/pull/1214 -->
    
    ### Check List (For Reviewer who merge this PR)
    
    - [ ] Confirm the release note
    - [ ] Confirm test cases
    - [ ] Confirm document
    - [ ] Add branch pick label <!-- Add branch pick label that this PR
    should merge into -->
---
 be/src/runtime/primitive_type.h                    | 38 ---------
 be/src/runtime/runtime_predicate.cpp               |  1 -
 .../aggregate_functions/aggregate_function_uniq.h  | 15 +---
 .../aggregate_function_uniq_distribute_key.h       |  7 +-
 be/src/vec/columns/column_decimal.h                |  2 +-
 be/src/vec/common/hash_table/hash.h                | 42 +++++++++
 be/src/vec/core/accurate_comparison.h              | 99 +++++++++++++---------
 be/src/vec/core/decimal_comparison.h               | 11 ++-
 be/src/vec/core/field.h                            | 77 -----------------
 be/src/vec/data_types/data_type_decimal.h          | 28 +++---
 be/src/vec/data_types/data_type_varbinary.h        |  1 -
 .../serde/data_type_date_or_datetime_serde.h       |  3 +-
 be/src/vec/exec/format/format_common.h             |  7 +-
 be/src/vec/functions/binary_arithmetic.h           |  4 +-
 be/src/vec/functions/divide.cpp                    | 19 ++---
 be/src/vec/functions/function_bit.cpp              |  6 +-
 be/src/vec/functions/function_convert_tz.cpp       |  1 -
 be/src/vec/functions/minus.cpp                     | 18 ++--
 be/src/vec/functions/modulo.cpp                    | 32 +++----
 be/src/vec/functions/multiply.cpp                  | 28 +++---
 be/src/vec/functions/plus.cpp                      | 18 ++--
 be/src/vec/functions/round.h                       | 30 ++++++-
 be/src/vec/sink/vtablet_block_convertor.cpp        |  6 +-
 23 files changed, 231 insertions(+), 262 deletions(-)

diff --git a/be/src/runtime/primitive_type.h b/be/src/runtime/primitive_type.h
index 9ba2e7452cf..1839e942e76 100644
--- a/be/src/runtime/primitive_type.h
+++ b/be/src/runtime/primitive_type.h
@@ -266,7 +266,6 @@ struct PrimitiveTypeTraits;
 /**
  * CppType: Doris type in execution engine
  * StorageFieldType: Doris type in storage engine
- * CppNativeType: Native type in C++ mapping to `CppType`. (e.g. VecDateTime 
<-> Int64)
  * DataType: DataType which is mapping to this PrimitiveType
  * ColumnType: ColumnType which is mapping to this PrimitiveType
  */
@@ -274,7 +273,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_BOOLEAN> {
     using CppType = vectorized::UInt8;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeBool;
     using ColumnType = vectorized::ColumnUInt8;
 };
@@ -282,7 +280,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_TINYINT> {
     using CppType = int8_t;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeInt8;
     using ColumnType = vectorized::ColumnInt8;
 };
@@ -290,7 +287,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_SMALLINT> {
     using CppType = int16_t;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeInt16;
     using ColumnType = vectorized::ColumnInt16;
 };
@@ -298,7 +294,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_INT> {
     using CppType = int32_t;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeInt32;
     using ColumnType = vectorized::ColumnInt32;
 };
@@ -306,7 +301,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_BIGINT> {
     using CppType = int64_t;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeInt64;
     using ColumnType = vectorized::ColumnInt64;
 };
@@ -314,7 +308,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_LARGEINT> {
     using CppType = __int128_t;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeInt128;
     using ColumnType = vectorized::ColumnInt128;
 };
@@ -322,7 +315,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_NULL> {
     using CppType = vectorized::Null;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeNothing;
     using ColumnType = vectorized::IColumnDummy;
 };
@@ -330,7 +322,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_FLOAT> {
     using CppType = float;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeFloat32;
     using ColumnType = vectorized::ColumnFloat32;
 };
@@ -338,7 +329,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DOUBLE> {
     using CppType = double;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeFloat64;
     using ColumnType = vectorized::ColumnFloat64;
 };
@@ -346,7 +336,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_TIMEV2> {
     using CppType = vectorized::Float64;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeTimeV2;
     using ColumnType = vectorized::ColumnTimeV2;
 };
@@ -354,7 +343,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_TIME> {
     using CppType = vectorized::Float64;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeTimeV2;
     using ColumnType = vectorized::ColumnTime;
 };
@@ -363,7 +351,6 @@ struct PrimitiveTypeTraits<TYPE_DATE> {
     using CppType = doris::VecDateTimeValue;
     /// Different with compute layer, the DateV1 was stored as uint24_t(3 
bytes).
     using StorageFieldType = uint24_t;
-    using CppNativeType = vectorized::Int64;
     using DataType = vectorized::DataTypeDate;
     using ColumnType = vectorized::ColumnDate;
 };
@@ -371,7 +358,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DATETIME> {
     using CppType = doris::VecDateTimeValue;
     using StorageFieldType = uint64_t;
-    using CppNativeType = vectorized::Int64;
     using DataType = vectorized::DataTypeDateTime;
     using ColumnType = vectorized::ColumnDateTime;
 };
@@ -379,7 +365,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DATETIMEV2> {
     using CppType = DateV2Value<DateTimeV2ValueType>;
     using StorageFieldType = uint64_t;
-    using CppNativeType = uint64_t;
     using DataType = vectorized::DataTypeDateTimeV2;
     using ColumnType = vectorized::ColumnDateTimeV2;
 };
@@ -387,7 +372,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DATEV2> {
     using CppType = DateV2Value<DateV2ValueType>;
     using StorageFieldType = uint32_t;
-    using CppNativeType = uint32_t;
     using DataType = vectorized::DataTypeDateV2;
     using ColumnType = vectorized::ColumnDateV2;
 };
@@ -396,7 +380,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_TIMESTAMPTZ> {
     using CppType = TimestampTzValue;
     using StorageFieldType = uint64_t;
-    using CppNativeType = uint64_t;
     using DataType = vectorized::DataTypeTimeStampTz;
     using ColumnType = vectorized::ColumnTimeStampTz;
 };
@@ -406,7 +389,6 @@ struct PrimitiveTypeTraits<TYPE_DECIMALV2> {
     using CppType = DecimalV2Value;
     /// Different with compute layer, the DecimalV1 was stored as 
decimal12_t(12 bytes).
     using StorageFieldType = decimal12_t;
-    using CppNativeType = vectorized::Int128;
     using DataType = vectorized::DataTypeDecimalV2;
     using ColumnType = vectorized::ColumnDecimal128V2;
 };
@@ -414,7 +396,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DECIMAL32> {
     using CppType = vectorized::Decimal32;
     using StorageFieldType = vectorized::Int32;
-    using CppNativeType = vectorized::Int32;
     using DataType = vectorized::DataTypeDecimal32;
     using ColumnType = vectorized::ColumnDecimal32;
 };
@@ -422,7 +403,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DECIMAL64> {
     using CppType = vectorized::Decimal64;
     using StorageFieldType = vectorized::Int64;
-    using CppNativeType = vectorized::Int64;
     using DataType = vectorized::DataTypeDecimal64;
     using ColumnType = vectorized::ColumnDecimal64;
 };
@@ -430,7 +410,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DECIMAL128I> {
     using CppType = vectorized::Decimal128V3;
     using StorageFieldType = vectorized::Int128;
-    using CppNativeType = vectorized::Int128;
     using DataType = vectorized::DataTypeDecimal128;
     using ColumnType = vectorized::ColumnDecimal128V3;
 };
@@ -438,7 +417,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_DECIMAL256> {
     using CppType = vectorized::Decimal256;
     using StorageFieldType = wide::Int256;
-    using CppNativeType = wide::Int256;
     using DataType = vectorized::DataTypeDecimal256;
     using ColumnType = vectorized::ColumnDecimal256;
 };
@@ -446,7 +424,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_IPV4> {
     using CppType = IPv4;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeIPv4;
     using ColumnType = vectorized::ColumnIPv4;
 };
@@ -454,7 +431,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_IPV6> {
     using CppType = IPv6;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeIPv6;
     using ColumnType = vectorized::ColumnIPv6;
 };
@@ -462,7 +438,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_CHAR> {
     using CppType = vectorized::String;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeString;
     using ColumnType = vectorized::ColumnString;
 };
@@ -470,7 +445,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_VARCHAR> {
     using CppType = vectorized::String;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeString;
     using ColumnType = vectorized::ColumnString;
 };
@@ -478,7 +452,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_STRING> {
     using CppType = vectorized::String;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeString;
     using ColumnType = vectorized::ColumnString;
 };
@@ -486,7 +459,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_VARBINARY> {
     using CppType = doris::StringView;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeVarbinary;
     using ColumnType = vectorized::ColumnVarbinary;
 };
@@ -494,7 +466,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_HLL> {
     using CppType = HyperLogLog;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeHLL;
     using ColumnType = vectorized::ColumnHLL;
 };
@@ -502,7 +473,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_JSONB> {
     using CppType = vectorized::JsonbField;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeJsonb;
     using ColumnType = vectorized::ColumnString;
 };
@@ -510,7 +480,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_ARRAY> {
     using CppType = vectorized::Array;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeArray;
     using ColumnType = vectorized::ColumnArray;
 };
@@ -518,7 +487,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_MAP> {
     using CppType = vectorized::Map;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeMap;
     using ColumnType = vectorized::ColumnMap;
 };
@@ -526,7 +494,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_STRUCT> {
     using CppType = vectorized::Tuple;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeStruct;
     using ColumnType = vectorized::ColumnStruct;
 };
@@ -534,7 +501,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_VARIANT> {
     using CppType = vectorized::VariantMap;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeVariant;
     using ColumnType = vectorized::ColumnVariant;
 };
@@ -542,7 +508,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_BITMAP> {
     using CppType = BitmapValue;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeBitMap;
     using ColumnType = vectorized::ColumnBitmap;
 };
@@ -550,7 +515,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_QUANTILE_STATE> {
     using CppType = QuantileState;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeQuantileState;
     using ColumnType = vectorized::ColumnQuantileState;
 };
@@ -558,7 +522,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_UINT32> {
     using CppType = vectorized::UInt32;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeNothing;
     using ColumnType = vectorized::ColumnOffset32;
 };
@@ -566,7 +529,6 @@ template <>
 struct PrimitiveTypeTraits<TYPE_UINT64> {
     using CppType = vectorized::UInt64;
     using StorageFieldType = CppType;
-    using CppNativeType = CppType;
     using DataType = vectorized::DataTypeNothing;
     using ColumnType = vectorized::ColumnOffset64;
 };
diff --git a/be/src/runtime/runtime_predicate.cpp 
b/be/src/runtime/runtime_predicate.cpp
index 3a5ec350001..98cc296ec93 100644
--- a/be/src/runtime/runtime_predicate.cpp
+++ b/be/src/runtime/runtime_predicate.cpp
@@ -165,7 +165,6 @@ StringRef RuntimePredicate::_get_string_ref(const Field& 
field, const PrimitiveT
         return StringRef((char*)&v, sizeof(v));
     }
     case doris::PrimitiveType::TYPE_VARBINARY: {
-        // For VARBINARY type, use StringViewField to store binary data
         const auto& v = field.get<TYPE_VARBINARY>();
         auto length = v.size();
         char* buffer = _predicate_arena.alloc(length);
diff --git a/be/src/vec/aggregate_functions/aggregate_function_uniq.h 
b/be/src/vec/aggregate_functions/aggregate_function_uniq.h
index de9989ec961..ebe5bdfb3ca 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_uniq.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_uniq.h
@@ -60,13 +60,9 @@ struct AggregateFunctionUniqExactData {
     static constexpr bool is_string_key = is_string_type(T) || is_varbinary(T);
     using Key = std::conditional_t<
             is_string_key, UInt128,
-            std::conditional_t<
-                    T == TYPE_ARRAY, UInt64,
-                    std::conditional_t<
-                            T == TYPE_BOOLEAN, UInt8,
-                            std::conditional_t<is_date_type(T) || T == 
TYPE_TIMESTAMPTZ,
-                                               typename 
PrimitiveTypeTraits<T>::CppType,
-                                               typename 
PrimitiveTypeTraits<T>::CppNativeType>>>>;
+            std::conditional_t<T == TYPE_ARRAY, UInt64,
+                               std::conditional_t<T == TYPE_BOOLEAN, UInt8,
+                                                  typename 
PrimitiveTypeTraits<T>::CppType>>>;
     using Hash = HashCRC32<Key>;
 
     using Set = flat_hash_set<Key, Hash>;
@@ -101,11 +97,6 @@ struct OneAdder {
             data.set.insert(Data::get_key(value));
         } else if constexpr (T == TYPE_ARRAY) {
             data.set.insert(Data::get_key(column, row_num));
-        } else if constexpr (is_decimal(T)) {
-            data.set.insert(assert_cast<const typename 
PrimitiveTypeTraits<T>::ColumnType&,
-                                        TypeCheckOnRelease::DISABLE>(column)
-                                    .get_data()[row_num]
-                                    .value);
         } else {
             data.set.insert(assert_cast<const typename 
PrimitiveTypeTraits<T>::ColumnType&,
                                         TypeCheckOnRelease::DISABLE>(column)
diff --git 
a/be/src/vec/aggregate_functions/aggregate_function_uniq_distribute_key.h 
b/be/src/vec/aggregate_functions/aggregate_function_uniq_distribute_key.h
index d73e41234ff..536a64af602 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_uniq_distribute_key.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_uniq_distribute_key.h
@@ -50,10 +50,9 @@ class BufferWritable;
 template <PrimitiveType T>
 struct AggregateFunctionUniqDistributeKeyData {
     static constexpr bool is_string_key = is_string_type(T);
-    using Key =
-            std::conditional_t<is_string_key, UInt128,
-                               std::conditional_t<T == TYPE_BOOLEAN, UInt8,
-                                                  typename 
PrimitiveTypeTraits<T>::CppNativeType>>;
+    using Key = std::conditional_t<
+            is_string_key, UInt128,
+            std::conditional_t<T == TYPE_BOOLEAN, UInt8, typename 
PrimitiveTypeTraits<T>::CppType>>;
     using Hash = std::conditional_t<is_string_key, UInt128TrivialHash, 
HashCRC32<Key>>;
 
     using Set = flat_hash_set<Key, Hash>;
diff --git a/be/src/vec/columns/column_decimal.h 
b/be/src/vec/columns/column_decimal.h
index 3f4bc360c7f..7bca9f221b0 100644
--- a/be/src/vec/columns/column_decimal.h
+++ b/be/src/vec/columns/column_decimal.h
@@ -87,7 +87,7 @@ private:
 public:
     // value_type is decimal32/64/128/256 type
     using value_type = typename PrimitiveTypeTraits<T>::CppType;
-    using CppNativeType = typename PrimitiveTypeTraits<T>::CppNativeType;
+    using CppNativeType = value_type::NativeType;
     using Container = DecimalPaddedPODArray<value_type>;
 
 private:
diff --git a/be/src/vec/common/hash_table/hash.h 
b/be/src/vec/common/hash_table/hash.h
index c1b9e1b9543..786a19ba2af 100644
--- a/be/src/vec/common/hash_table/hash.h
+++ b/be/src/vec/common/hash_table/hash.h
@@ -239,6 +239,48 @@ struct HashCRC32<wide::Int256> {
     }
 };
 
+template <>
+struct HashCRC32<doris::vectorized::Decimal256> {
+    size_t operator()(const doris::vectorized::Decimal256& value) const {
+        return HashCRC32<wide::Int256>()(value.value);
+    }
+};
+
+template <>
+struct HashCRC32<doris::vectorized::Decimal32> {
+    size_t operator()(const doris::vectorized::Decimal32& value) const {
+        return HashCRC32<int32_t>()(value.value);
+    }
+};
+
+template <>
+struct HashCRC32<doris::vectorized::Decimal64> {
+    size_t operator()(const doris::vectorized::Decimal64& value) const {
+        return HashCRC32<int64_t>()(value.value);
+    }
+};
+
+template <>
+struct HashCRC32<doris::vectorized::Decimal128V3> {
+    size_t operator()(const doris::vectorized::Decimal128V3& value) const {
+        return HashCRC32<__int128>()(value.value);
+    }
+};
+
+template <>
+struct HashCRC32<doris::vectorized::Decimal128V2> {
+    size_t operator()(const doris::vectorized::Decimal128V2& value) const {
+        return HashCRC32<__int128>()(value.value);
+    }
+};
+
+template <>
+struct HashCRC32<doris::DecimalV2Value> {
+    size_t operator()(const doris::DecimalV2Value& value) const {
+        return HashCRC32<__int128>()(value.value());
+    }
+};
+
 #include "common/compile_check_avoid_begin.h"
 
 template <>
diff --git a/be/src/vec/core/accurate_comparison.h 
b/be/src/vec/core/accurate_comparison.h
index af4dfe42712..85c40f52ecc 100644
--- a/be/src/vec/core/accurate_comparison.h
+++ b/be/src/vec/core/accurate_comparison.h
@@ -27,15 +27,36 @@
 namespace doris::vectorized {
 
 template <PrimitiveType PT>
-using CompareType =
-        std::conditional_t<PT == TYPE_BOOLEAN, typename 
PrimitiveTypeTraits<PT>::CppType,
-                           typename PrimitiveTypeTraits<PT>::CppNativeType>;
+struct CompareType {
+    using NativeType = typename PrimitiveTypeTraits<PT>::CppType;
+};
+
+template <>
+struct CompareType<TYPE_DECIMAL32> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL32>::CppType::NativeType;
+};
+template <>
+struct CompareType<TYPE_DECIMAL64> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL64>::CppType::NativeType;
+};
+template <>
+struct CompareType<TYPE_DECIMAL128I> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL128I>::CppType::NativeType;
+};
+template <>
+struct CompareType<TYPE_DECIMALV2> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMALV2>::CppType::NativeType;
+};
+template <>
+struct CompareType<TYPE_DECIMAL256> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL256>::CppType::NativeType;
+};
 
 template <PrimitiveType PT>
 struct EqualsOp {
     /// An operation that gives the same result, if arguments are passed in 
reverse order.
     using SymmetricOp = EqualsOp<PT>;
-    using NativeType = CompareType<PT>;
+    using NativeType = typename CompareType<PT>::NativeType;
 
     static UInt8 apply(NativeType a, NativeType b) { return Compare::equal(a, 
b); }
 };
@@ -48,21 +69,21 @@ struct EqualsOp<TYPE_DECIMALV2> {
 template <>
 struct EqualsOp<TYPE_DATE> {
     using SymmetricOp = EqualsOp<TYPE_DATE>;
-    using NativeType = CompareType<TYPE_DATE>;
+    using NativeType = typename CompareType<TYPE_DATE>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a == b; }
 };
 
 template <>
 struct EqualsOp<TYPE_DATETIME> {
     using SymmetricOp = EqualsOp<TYPE_DATETIME>;
-    using NativeType = CompareType<TYPE_DATETIME>;
+    using NativeType = typename CompareType<TYPE_DATETIME>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a == b; }
 };
 
 template <>
 struct EqualsOp<TYPE_DATEV2> {
     using SymmetricOp = EqualsOp<TYPE_DATEV2>;
-    using NativeType = CompareType<TYPE_DATEV2>;
+    using NativeType = typename CompareType<TYPE_DATEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateV2ValueType>& a,
                        const DateV2Value<DateV2ValueType>& b) {
         return a == b;
@@ -72,7 +93,7 @@ struct EqualsOp<TYPE_DATEV2> {
 template <>
 struct EqualsOp<TYPE_DATETIMEV2> {
     using SymmetricOp = EqualsOp<TYPE_DATETIMEV2>;
-    using NativeType = CompareType<TYPE_DATETIMEV2>;
+    using NativeType = typename CompareType<TYPE_DATETIMEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateTimeV2ValueType>& a,
                        const DateV2Value<DateTimeV2ValueType>& b) {
         return a == b;
@@ -82,7 +103,7 @@ struct EqualsOp<TYPE_DATETIMEV2> {
 template <>
 struct EqualsOp<TYPE_TIMESTAMPTZ> {
     using SymmetricOp = EqualsOp<TYPE_TIMESTAMPTZ>;
-    using NativeType = CompareType<TYPE_TIMESTAMPTZ>;
+    using NativeType = typename CompareType<TYPE_TIMESTAMPTZ>::NativeType;
     static UInt8 apply(const TimestampTzValue& a, const TimestampTzValue& b) { 
return a == b; }
 };
 
@@ -94,7 +115,7 @@ struct EqualsOp<TYPE_STRING> {
 template <PrimitiveType PT>
 struct NotEqualsOp {
     using SymmetricOp = NotEqualsOp<PT>;
-    using NativeType = CompareType<PT>;
+    using NativeType = typename CompareType<PT>::NativeType;
     static UInt8 apply(NativeType a, NativeType b) { return 
Compare::not_equal(a, b); }
 };
 
@@ -106,21 +127,21 @@ struct NotEqualsOp<TYPE_DECIMALV2> {
 template <>
 struct NotEqualsOp<TYPE_DATE> {
     using SymmetricOp = NotEqualsOp<TYPE_DATE>;
-    using NativeType = CompareType<TYPE_DATE>;
+    using NativeType = typename CompareType<TYPE_DATE>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a != b; }
 };
 
 template <>
 struct NotEqualsOp<TYPE_DATETIME> {
     using SymmetricOp = NotEqualsOp<TYPE_DATETIME>;
-    using NativeType = CompareType<TYPE_DATETIME>;
+    using NativeType = typename CompareType<TYPE_DATETIME>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a != b; }
 };
 
 template <>
 struct NotEqualsOp<TYPE_DATEV2> {
     using SymmetricOp = NotEqualsOp<TYPE_DATEV2>;
-    using NativeType = CompareType<TYPE_DATEV2>;
+    using NativeType = typename CompareType<TYPE_DATEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateV2ValueType>& a,
                        const DateV2Value<DateV2ValueType>& b) {
         return a != b;
@@ -130,7 +151,7 @@ struct NotEqualsOp<TYPE_DATEV2> {
 template <>
 struct NotEqualsOp<TYPE_DATETIMEV2> {
     using SymmetricOp = NotEqualsOp<TYPE_DATETIMEV2>;
-    using NativeType = CompareType<TYPE_DATETIMEV2>;
+    using NativeType = typename CompareType<TYPE_DATETIMEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateTimeV2ValueType>& a,
                        const DateV2Value<DateTimeV2ValueType>& b) {
         return a != b;
@@ -140,7 +161,7 @@ struct NotEqualsOp<TYPE_DATETIMEV2> {
 template <>
 struct NotEqualsOp<TYPE_TIMESTAMPTZ> {
     using SymmetricOp = NotEqualsOp<TYPE_TIMESTAMPTZ>;
-    using NativeType = CompareType<TYPE_TIMESTAMPTZ>;
+    using NativeType = typename CompareType<TYPE_TIMESTAMPTZ>::NativeType;
     static UInt8 apply(const TimestampTzValue& a, const TimestampTzValue& b) { 
return a != b; }
 };
 
@@ -150,7 +171,7 @@ struct GreaterOp;
 template <PrimitiveType PT>
 struct LessOp {
     using SymmetricOp = GreaterOp<PT>;
-    using NativeType = CompareType<PT>;
+    using NativeType = typename CompareType<PT>::NativeType;
     static UInt8 apply(NativeType a, NativeType b) { return Compare::less(a, 
b); }
 };
 
@@ -162,21 +183,21 @@ struct LessOp<TYPE_DECIMALV2> {
 template <>
 struct LessOp<TYPE_DATE> {
     using SymmetricOp = GreaterOp<TYPE_DATE>;
-    using NativeType = CompareType<TYPE_DATE>;
+    using NativeType = typename CompareType<TYPE_DATE>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a < b; }
 };
 
 template <>
 struct LessOp<TYPE_DATETIME> {
     using SymmetricOp = GreaterOp<TYPE_DATETIME>;
-    using NativeType = CompareType<TYPE_DATETIME>;
+    using NativeType = typename CompareType<TYPE_DATETIME>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a < b; }
 };
 
 template <>
 struct LessOp<TYPE_DATEV2> {
     using SymmetricOp = GreaterOp<TYPE_DATEV2>;
-    using NativeType = CompareType<TYPE_DATEV2>;
+    using NativeType = typename CompareType<TYPE_DATEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateV2ValueType>& a,
                        const DateV2Value<DateV2ValueType>& b) {
         return a < b;
@@ -186,7 +207,7 @@ struct LessOp<TYPE_DATEV2> {
 template <>
 struct LessOp<TYPE_DATETIMEV2> {
     using SymmetricOp = GreaterOp<TYPE_DATETIMEV2>;
-    using NativeType = CompareType<TYPE_DATETIMEV2>;
+    using NativeType = typename CompareType<TYPE_DATETIMEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateTimeV2ValueType>& a,
                        const DateV2Value<DateTimeV2ValueType>& b) {
         return a < b;
@@ -196,7 +217,7 @@ struct LessOp<TYPE_DATETIMEV2> {
 template <>
 struct LessOp<TYPE_TIMESTAMPTZ> {
     using SymmetricOp = GreaterOp<TYPE_TIMESTAMPTZ>;
-    using NativeType = CompareType<TYPE_TIMESTAMPTZ>;
+    using NativeType = typename CompareType<TYPE_TIMESTAMPTZ>::NativeType;
     static UInt8 apply(const TimestampTzValue& a, const TimestampTzValue& b) { 
return a < b; }
 };
 
@@ -208,7 +229,7 @@ struct LessOp<TYPE_STRING> {
 template <PrimitiveType PT>
 struct GreaterOp {
     using SymmetricOp = LessOp<PT>;
-    using NativeType = CompareType<PT>;
+    using NativeType = typename CompareType<PT>::NativeType;
     static UInt8 apply(NativeType a, NativeType b) { return 
Compare::greater(a, b); }
 };
 
@@ -220,21 +241,21 @@ struct GreaterOp<TYPE_DECIMALV2> {
 template <>
 struct GreaterOp<TYPE_DATE> {
     using SymmetricOp = LessOp<TYPE_DATE>;
-    using NativeType = CompareType<TYPE_DATE>;
+    using NativeType = typename CompareType<TYPE_DATE>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a > b; }
 };
 
 template <>
 struct GreaterOp<TYPE_DATETIME> {
     using SymmetricOp = LessOp<TYPE_DATETIME>;
-    using NativeType = CompareType<TYPE_DATETIME>;
+    using NativeType = typename CompareType<TYPE_DATETIME>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a > b; }
 };
 
 template <>
 struct GreaterOp<TYPE_DATEV2> {
     using SymmetricOp = LessOp<TYPE_DATEV2>;
-    using NativeType = CompareType<TYPE_DATEV2>;
+    using NativeType = typename CompareType<TYPE_DATEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateV2ValueType>& a,
                        const DateV2Value<DateV2ValueType>& b) {
         return a > b;
@@ -244,7 +265,7 @@ struct GreaterOp<TYPE_DATEV2> {
 template <>
 struct GreaterOp<TYPE_DATETIMEV2> {
     using SymmetricOp = LessOp<TYPE_DATETIMEV2>;
-    using NativeType = CompareType<TYPE_DATETIMEV2>;
+    using NativeType = typename CompareType<TYPE_DATETIMEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateTimeV2ValueType>& a,
                        const DateV2Value<DateTimeV2ValueType>& b) {
         return a > b;
@@ -254,7 +275,7 @@ struct GreaterOp<TYPE_DATETIMEV2> {
 template <>
 struct GreaterOp<TYPE_TIMESTAMPTZ> {
     using SymmetricOp = LessOp<TYPE_TIMESTAMPTZ>;
-    using NativeType = CompareType<TYPE_TIMESTAMPTZ>;
+    using NativeType = typename CompareType<TYPE_TIMESTAMPTZ>::NativeType;
     static UInt8 apply(const TimestampTzValue& a, const TimestampTzValue& b) { 
return a > b; }
 };
 
@@ -269,7 +290,7 @@ struct GreaterOrEqualsOp;
 template <PrimitiveType PT>
 struct LessOrEqualsOp {
     using SymmetricOp = GreaterOrEqualsOp<PT>;
-    using NativeType = CompareType<PT>;
+    using NativeType = typename CompareType<PT>::NativeType;
     static UInt8 apply(NativeType a, NativeType b) { return 
Compare::less_equal(a, b); }
 };
 
@@ -281,21 +302,21 @@ struct LessOrEqualsOp<TYPE_DECIMALV2> {
 template <>
 struct LessOrEqualsOp<TYPE_DATE> {
     using SymmetricOp = GreaterOrEqualsOp<TYPE_DATE>;
-    using NativeType = CompareType<TYPE_DATE>;
+    using NativeType = typename CompareType<TYPE_DATE>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a <= b; }
 };
 
 template <>
 struct LessOrEqualsOp<TYPE_DATETIME> {
     using SymmetricOp = GreaterOrEqualsOp<TYPE_DATETIME>;
-    using NativeType = CompareType<TYPE_DATETIME>;
+    using NativeType = typename CompareType<TYPE_DATETIME>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a <= b; }
 };
 
 template <>
 struct LessOrEqualsOp<TYPE_DATEV2> {
     using SymmetricOp = GreaterOrEqualsOp<TYPE_DATEV2>;
-    using NativeType = CompareType<TYPE_DATEV2>;
+    using NativeType = typename CompareType<TYPE_DATEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateV2ValueType>& a,
                        const DateV2Value<DateV2ValueType>& b) {
         return a <= b;
@@ -305,7 +326,7 @@ struct LessOrEqualsOp<TYPE_DATEV2> {
 template <>
 struct LessOrEqualsOp<TYPE_DATETIMEV2> {
     using SymmetricOp = GreaterOrEqualsOp<TYPE_DATETIMEV2>;
-    using NativeType = CompareType<TYPE_DATETIMEV2>;
+    using NativeType = typename CompareType<TYPE_DATETIMEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateTimeV2ValueType>& a,
                        const DateV2Value<DateTimeV2ValueType>& b) {
         return a <= b;
@@ -315,14 +336,14 @@ struct LessOrEqualsOp<TYPE_DATETIMEV2> {
 template <>
 struct LessOrEqualsOp<TYPE_TIMESTAMPTZ> {
     using SymmetricOp = GreaterOrEqualsOp<TYPE_TIMESTAMPTZ>;
-    using NativeType = CompareType<TYPE_TIMESTAMPTZ>;
+    using NativeType = typename CompareType<TYPE_TIMESTAMPTZ>::NativeType;
     static UInt8 apply(const TimestampTzValue& a, const TimestampTzValue& b) { 
return a <= b; }
 };
 
 template <PrimitiveType PT>
 struct GreaterOrEqualsOp {
     using SymmetricOp = LessOrEqualsOp<PT>;
-    using NativeType = CompareType<PT>;
+    using NativeType = typename CompareType<PT>::NativeType;
     static UInt8 apply(NativeType a, NativeType b) { return 
Compare::greater_equal(a, b); }
 };
 
@@ -334,21 +355,21 @@ struct GreaterOrEqualsOp<TYPE_DECIMALV2> {
 template <>
 struct GreaterOrEqualsOp<TYPE_DATE> {
     using SymmetricOp = LessOrEqualsOp<TYPE_DATE>;
-    using NativeType = CompareType<TYPE_DATE>;
+    using NativeType = typename CompareType<TYPE_DATE>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a >= b; }
 };
 
 template <>
 struct GreaterOrEqualsOp<TYPE_DATETIME> {
     using SymmetricOp = LessOrEqualsOp<TYPE_DATETIME>;
-    using NativeType = CompareType<TYPE_DATETIME>;
+    using NativeType = typename CompareType<TYPE_DATETIME>::NativeType;
     static UInt8 apply(const VecDateTimeValue& a, const VecDateTimeValue& b) { 
return a >= b; }
 };
 
 template <>
 struct GreaterOrEqualsOp<TYPE_DATEV2> {
     using SymmetricOp = LessOrEqualsOp<TYPE_DATEV2>;
-    using NativeType = CompareType<TYPE_DATEV2>;
+    using NativeType = typename CompareType<TYPE_DATEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateV2ValueType>& a,
                        const DateV2Value<DateV2ValueType>& b) {
         return a >= b;
@@ -358,7 +379,7 @@ struct GreaterOrEqualsOp<TYPE_DATEV2> {
 template <>
 struct GreaterOrEqualsOp<TYPE_DATETIMEV2> {
     using SymmetricOp = LessOrEqualsOp<TYPE_DATETIMEV2>;
-    using NativeType = CompareType<TYPE_DATETIMEV2>;
+    using NativeType = typename CompareType<TYPE_DATETIMEV2>::NativeType;
     static UInt8 apply(const DateV2Value<DateTimeV2ValueType>& a,
                        const DateV2Value<DateTimeV2ValueType>& b) {
         return a >= b;
@@ -368,7 +389,7 @@ struct GreaterOrEqualsOp<TYPE_DATETIMEV2> {
 template <>
 struct GreaterOrEqualsOp<TYPE_TIMESTAMPTZ> {
     using SymmetricOp = LessOrEqualsOp<TYPE_TIMESTAMPTZ>;
-    using NativeType = CompareType<TYPE_TIMESTAMPTZ>;
+    using NativeType = typename CompareType<TYPE_TIMESTAMPTZ>::NativeType;
     static UInt8 apply(const TimestampTzValue& a, const TimestampTzValue& b) { 
return a >= b; }
 };
 
diff --git a/be/src/vec/core/decimal_comparison.h 
b/be/src/vec/core/decimal_comparison.h
index 6d8923ea3ea..aa78ce22b8f 100644
--- a/be/src/vec/core/decimal_comparison.h
+++ b/be/src/vec/core/decimal_comparison.h
@@ -35,18 +35,22 @@ namespace doris::vectorized {
 template <size_t>
 struct ConstructDecInt {
     static constexpr PrimitiveType Type = TYPE_INT;
+    using CompareInt = Int32;
 };
 template <>
 struct ConstructDecInt<8> {
     static constexpr PrimitiveType Type = TYPE_BIGINT;
+    using CompareInt = Int64;
 };
 template <>
 struct ConstructDecInt<16> {
     static constexpr PrimitiveType Type = TYPE_LARGEINT;
+    using CompareInt = Int128;
 };
 template <>
 struct ConstructDecInt<32> {
     static constexpr PrimitiveType Type = TYPE_DECIMAL256;
+    using CompareInt = wide::Int256;
 };
 
 template <PrimitiveType T, PrimitiveType U>
@@ -57,6 +61,11 @@ struct DecCompareInt {
                                        sizeof(typename 
PrimitiveTypeTraits<U>::CppType))
                     ? sizeof(typename PrimitiveTypeTraits<T>::CppType)
                     : sizeof(typename PrimitiveTypeTraits<U>::CppType) > 
::Type;
+    using CompareInt = typename ConstructDecInt<
+            (!is_decimal(U) || sizeof(typename 
PrimitiveTypeTraits<T>::CppType) >
+                                       sizeof(typename 
PrimitiveTypeTraits<U>::CppType))
+                    ? sizeof(typename PrimitiveTypeTraits<T>::CppType)
+                    : sizeof(typename 
PrimitiveTypeTraits<U>::CppType)>::CompareInt;
 };
 
 ///
@@ -65,7 +74,7 @@ template <PrimitiveType A, PrimitiveType B, template 
<PrimitiveType> typename Op
 class DecimalComparison {
 public:
     static constexpr PrimitiveType CompareIntPType = DecCompareInt<A, B>::Type;
-    using CompareInt = typename 
PrimitiveTypeTraits<CompareIntPType>::CppNativeType;
+    using CompareInt = typename DecCompareInt<A, B>::CompareInt;
     using Op = Operation<CompareIntPType>;
     using ColVecA = typename PrimitiveTypeTraits<A>::ColumnType;
     using ColVecB = typename PrimitiveTypeTraits<B>::ColumnType;
diff --git a/be/src/vec/core/field.h b/be/src/vec/core/field.h
index 1cb6d0c13a3..2a2eb00c4a4 100644
--- a/be/src/vec/core/field.h
+++ b/be/src/vec/core/field.h
@@ -175,83 +175,6 @@ bool decimal_less(T x, T y, UInt32 x_scale, UInt32 
y_scale);
 template <typename T>
 bool decimal_less_or_equal(T x, T y, UInt32 x_scale, UInt32 y_scale);
 
-// StringViewField wraps a StringView and provides deep copy semantics.
-// Since StringView is a non-owning view (only contains pointer and length),
-// we need to store the actual data in a String to ensure the Field owns the 
data.
-// This prevents dangling pointer issues when Field objects are copied or 
moved.
-class StringViewField {
-public:
-    StringViewField() = default;
-    ~StringViewField() = default;
-
-    // Construct from raw data - performs deep copy
-    StringViewField(const char* data, size_t len) : _storage(data, len) {}
-
-    // Construct from StringView - performs deep copy
-    StringViewField(const StringView& sv) : _storage(sv.data(), sv.size()) {}
-
-    // Copy constructor - deep copy
-    StringViewField(const StringViewField& x) = default;
-
-    // Move constructor
-    StringViewField(StringViewField&& x) noexcept = default;
-
-    // Copy assignment - deep copy
-    StringViewField& operator=(const StringViewField& x) = default;
-
-    // Move assignment
-    StringViewField& operator=(StringViewField&& x) noexcept = default;
-
-    // Access methods
-    const char* data() const { return _storage.data(); }
-    size_t size() const { return _storage.size(); }
-    const String& get_string() const { return _storage; }
-
-    // Convert to StringView for compatibility
-    StringView to_string_view() const { return {data(), 
static_cast<uint32_t>(size())}; }
-
-    // Comparison operators - using binary comparison (memcmp) for VARBINARY 
semantics
-    bool operator<(const StringViewField& r) const {
-        int cmp = memcmp(_storage.data(), r._storage.data(),
-                         std::min(_storage.size(), r._storage.size()));
-        return cmp < 0 || (cmp == 0 && _storage.size() < r._storage.size());
-    }
-    bool operator<=(const StringViewField& r) const { return !(r < *this); }
-    bool operator==(const StringViewField& r) const {
-        return _storage.size() == r._storage.size() &&
-               memcmp(_storage.data(), r._storage.data(), _storage.size()) == 
0;
-    }
-    bool operator>(const StringViewField& r) const { return r < *this; }
-    bool operator>=(const StringViewField& r) const { return !(*this < r); }
-    bool operator!=(const StringViewField& r) const { return !(*this == r); }
-
-    std::strong_ordering operator<=>(const StringViewField& r) const {
-        size_t min_size = std::min(_storage.size(), r._storage.size());
-        int cmp = memcmp(_storage.data(), r._storage.data(), min_size);
-        if (cmp < 0) {
-            return std::strong_ordering::less;
-        }
-        if (cmp > 0) {
-            return std::strong_ordering::greater;
-        }
-        // Prefixes are equal, compare lengths
-        return _storage.size() <=> r._storage.size();
-    }
-
-    // Arithmetic operators (not commonly used but required by Field)
-    const StringViewField& operator+=(const StringViewField& r) {
-        _storage += r._storage;
-        return *this;
-    }
-
-    const StringViewField& operator-=(const StringViewField& r) {
-        throw Exception(Status::FatalError("Not support minus operation on 
StringViewField"));
-    }
-
-private:
-    String _storage; // Use String for deep copy and ownership
-};
-
 /** 32 is enough. Round number is used for alignment and for better arithmetic 
inside std::vector.
   * NOTE: Actually, sizeof(std::string) is 32 when using libc++, so Field is 
40 bytes.
   */
diff --git a/be/src/vec/data_types/data_type_decimal.h 
b/be/src/vec/data_types/data_type_decimal.h
index 76a15632984..ab027d5f33d 100644
--- a/be/src/vec/data_types/data_type_decimal.h
+++ b/be/src/vec/data_types/data_type_decimal.h
@@ -306,7 +306,9 @@ public:
             return scale;
         }
     }
-    FieldType::NativeType get_scale_multiplier() const { return 
get_scale_multiplier(scale); }
+    typename FieldType::NativeType get_scale_multiplier() const {
+        return get_scale_multiplier(scale);
+    }
     void to_protobuf(PTypeDesc* ptype, PTypeNode* node, PScalarType* 
scalar_type) const override {
         scalar_type->set_precision(precision);
         scalar_type->set_scale(scale);
@@ -314,7 +316,7 @@ public:
 
     /// @returns multiplier for U to become T with correct scale
     template <PrimitiveType U>
-    FieldType::NativeType scale_factor_for(const DataTypeDecimal<U>& x) const {
+    typename FieldType::NativeType scale_factor_for(const DataTypeDecimal<U>& 
x) const {
         if (get_scale() < x.get_scale()) {
             throw doris::Exception(ErrorCode::NOT_IMPLEMENTED_ERROR,
                                    "Decimal result's scale is less then 
argument's one");
@@ -324,9 +326,9 @@ public:
         return get_scale_multiplier(scale_delta);
     }
 
-    static constexpr FieldType::NativeType get_scale_multiplier(UInt32 scale);
+    static constexpr typename FieldType::NativeType 
get_scale_multiplier(UInt32 scale);
 
-    static constexpr FieldType::NativeType get_max_digits_number(UInt32 
digit_count);
+    static constexpr typename FieldType::NativeType 
get_max_digits_number(UInt32 digit_count);
 
     bool parse_from_string(const std::string& str, FieldType* res) const;
 
@@ -498,18 +500,20 @@ constexpr bool IsDataTypeDecimalOrNumber =
 
 template <PrimitiveType T>
     requires(is_decimal(T))
-typename PrimitiveTypeTraits<T>::CppNativeType max_decimal_value(UInt32 
precision) {
-    return type_limit<typename PrimitiveTypeTraits<T>::CppType>::max().value /
-           DataTypeDecimal<T>::get_scale_multiplier(
-                   (UInt32)(max_decimal_precision<T>() - precision));
+typename PrimitiveTypeTraits<T>::CppType max_decimal_value(UInt32 precision) {
+    return typename PrimitiveTypeTraits<T>::CppType(
+            type_limit<typename PrimitiveTypeTraits<T>::CppType>::max().value /
+            DataTypeDecimal<T>::get_scale_multiplier(
+                    (UInt32)(max_decimal_precision<T>() - precision)));
 }
 
 template <PrimitiveType T>
     requires(is_decimal(T))
-typename PrimitiveTypeTraits<T>::CppNativeType min_decimal_value(UInt32 
precision) {
-    return type_limit<typename PrimitiveTypeTraits<T>::CppType>::min().value /
-           DataTypeDecimal<T>::get_scale_multiplier(
-                   (UInt32)(max_decimal_precision<T>() - precision));
+typename PrimitiveTypeTraits<T>::CppType min_decimal_value(UInt32 precision) {
+    return typename PrimitiveTypeTraits<T>::CppType(
+            type_limit<typename PrimitiveTypeTraits<T>::CppType>::min().value /
+            DataTypeDecimal<T>::get_scale_multiplier(
+                    (UInt32)(max_decimal_precision<T>() - precision)));
 }
 
 template <typename T>
diff --git a/be/src/vec/data_types/data_type_varbinary.h 
b/be/src/vec/data_types/data_type_varbinary.h
index f84884d8e1b..45cba9bac42 100644
--- a/be/src/vec/data_types/data_type_varbinary.h
+++ b/be/src/vec/data_types/data_type_varbinary.h
@@ -40,7 +40,6 @@ class IColumn;
 class DataTypeVarbinary : public IDataType {
 public:
     using ColumnType = ColumnVarbinary;
-    using FieldType = StringViewField;
 
     static constexpr PrimitiveType PType = TYPE_VARBINARY;
 
diff --git a/be/src/vec/data_types/serde/data_type_date_or_datetime_serde.h 
b/be/src/vec/data_types/serde/data_type_date_or_datetime_serde.h
index 4e94f875f83..14e5da8bb86 100644
--- a/be/src/vec/data_types/serde/data_type_date_or_datetime_serde.h
+++ b/be/src/vec/data_types/serde/data_type_date_or_datetime_serde.h
@@ -42,8 +42,7 @@ public:
     static_assert(IsDatetime || T == PrimitiveType::TYPE_DATE,
                   "DataTypeDateSerDe can only be used for TYPE_DATE or 
TYPE_DATETIME");
     using ColumnType = typename PrimitiveTypeTraits<T>::ColumnType;
-    using NativeType = typename PrimitiveTypeTraits<T>::CppNativeType; // int64
-    using CppType = typename PrimitiveTypeTraits<T>::CppType;          // 
VecDateTimeValue
+    using CppType = typename PrimitiveTypeTraits<T>::CppType; // 
VecDateTimeValue
     constexpr static std::string_view name() { return IsDatetime ? "DateTime" 
: "Date"; }
 
     using typename DataTypeNumberSerDe<T>::FormatOptions;
diff --git a/be/src/vec/exec/format/format_common.h 
b/be/src/vec/exec/format/format_common.h
index 7411fad3f74..53b9fc9b59f 100644
--- a/be/src/vec/exec/format/format_common.h
+++ b/be/src/vec/exec/format/format_common.h
@@ -34,7 +34,7 @@ struct DecimalScaleParams {
     int64_t scale_factor = 1;
 
     template <PrimitiveType DecimalPrimitiveType>
-    static inline constexpr typename 
PrimitiveTypeTraits<DecimalPrimitiveType>::CppNativeType
+    static inline constexpr typename 
PrimitiveTypeTraits<DecimalPrimitiveType>::CppType::NativeType
     get_scale_factor(int32_t n) {
         if constexpr (DecimalPrimitiveType == TYPE_DECIMAL32) {
             return common::exp10_i32(n);
@@ -47,9 +47,8 @@ struct DecimalScaleParams {
         } else if constexpr (DecimalPrimitiveType == TYPE_DECIMAL256) {
             return common::exp10_i256(n);
         } else {
-            static_assert(
-                    !sizeof(typename 
PrimitiveTypeTraits<DecimalPrimitiveType>::CppNativeType),
-                    "All types must be matched with if constexpr.");
+            static_assert(!sizeof(typename 
PrimitiveTypeTraits<DecimalPrimitiveType>::CppType),
+                          "All types must be matched with if constexpr.");
         }
     }
 };
diff --git a/be/src/vec/functions/binary_arithmetic.h 
b/be/src/vec/functions/binary_arithmetic.h
index ecfd1ae263b..f9fa2d3c921 100644
--- a/be/src/vec/functions/binary_arithmetic.h
+++ b/be/src/vec/functions/binary_arithmetic.h
@@ -326,7 +326,7 @@ struct PlusMinusDecimalImpl {
 
     template <bool check_overflow, PrimitiveType ResultType>
         requires(is_decimal(ResultType))
-    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppNativeType apply(
+    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType apply(
             ArgNativeTypeA a, ArgNativeTypeB b, const DataTypeA& type_left,
             const DataTypeB& type_right, const DataTypeDecimal<ResultType>& 
type_result,
             const typename PrimitiveTypeTraits<ResultType>::CppType& 
max_result_number,
@@ -347,7 +347,7 @@ struct PlusMinusDecimalImpl {
                 return Impl::apply(DecimalV2Value(a), 
DecimalV2Value(b)).value();
             }
         } else {
-            typename PrimitiveTypeTraits<ResultType>::CppNativeType res;
+            typename PrimitiveTypeTraits<ResultType>::CppType::NativeType res;
             if constexpr (check_overflow) {
                 // TODO handle overflow gracefully
                 if (UNLIKELY(Impl::template apply<ResultType>(a, b, res))) {
diff --git a/be/src/vec/functions/divide.cpp b/be/src/vec/functions/divide.cpp
index 0029b3a30c7..bd4ff242cdd 100644
--- a/be/src/vec/functions/divide.cpp
+++ b/be/src/vec/functions/divide.cpp
@@ -318,8 +318,8 @@ private:
 static const DecimalV2Value one(1, 0);
 
 struct DivideFloatingImpl {
-    using ArgA = typename PrimitiveTypeTraits<TYPE_DOUBLE>::CppNativeType;
-    using ArgB = typename PrimitiveTypeTraits<TYPE_DOUBLE>::CppNativeType;
+    using ArgA = typename PrimitiveTypeTraits<TYPE_DOUBLE>::CppType;
+    using ArgB = typename PrimitiveTypeTraits<TYPE_DOUBLE>::CppType;
     static constexpr PrimitiveType ArgAPType = TYPE_DOUBLE;
     static constexpr PrimitiveType ArgBPType = TYPE_DOUBLE;
     using ColumnType = typename PrimitiveTypeTraits<TYPE_DOUBLE>::ColumnType;
@@ -413,8 +413,8 @@ struct DivideDecimalImpl {
     using ArgB = typename PrimitiveTypeTraits<TypeB>::CppType;
     static constexpr PrimitiveType ArgAPType = TypeA;
     static constexpr PrimitiveType ArgBPType = TypeB;
-    using ArgNativeTypeA = typename PrimitiveTypeTraits<TypeA>::CppNativeType;
-    using ArgNativeTypeB = typename PrimitiveTypeTraits<TypeB>::CppNativeType;
+    using ArgNativeTypeA = typename 
PrimitiveTypeTraits<TypeA>::CppType::NativeType;
+    using ArgNativeTypeB = typename 
PrimitiveTypeTraits<TypeB>::CppType::NativeType;
     using DataTypeA = typename PrimitiveTypeTraits<TypeA>::DataType;
     using DataTypeB = typename PrimitiveTypeTraits<TypeB>::DataType;
     using ColumnTypeA = typename PrimitiveTypeTraits<TypeA>::ColumnType;
@@ -434,11 +434,10 @@ struct DivideDecimalImpl {
 
     template <PrimitiveType ResultType>
         requires(is_decimal(ResultType))
-    static inline typename PrimitiveTypeTraits<ResultType>::CppNativeType 
impl(ArgNativeTypeA a,
-                                                                               
ArgNativeTypeB b,
-                                                                               
UInt8& is_null) {
+    static inline typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType impl(
+            ArgNativeTypeA a, ArgNativeTypeB b, UInt8& is_null) {
         is_null = b == 0;
-        return static_cast<typename 
PrimitiveTypeTraits<ResultType>::CppNativeType>(a) /
+        return static_cast<typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType>(a) /
                (b + is_null);
     }
 
@@ -667,7 +666,7 @@ struct DivideDecimalImpl {
 
     template <bool check_overflow_for_decimal, PrimitiveType ResultType>
         requires(is_decimal(ResultType))
-    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppNativeType apply(
+    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType apply(
             ArgNativeTypeA a, ArgNativeTypeB b, UInt8& is_null,
             const typename PrimitiveTypeTraits<ResultType>::CppType& 
max_result_number) {
         if constexpr (TypeA == TYPE_DECIMALV2) {
@@ -707,7 +706,7 @@ struct DivideDecimalImpl {
                     }
                 }
             }
-            typename PrimitiveTypeTraits<ResultType>::CppNativeType result {};
+            typename PrimitiveTypeTraits<ResultType>::CppType::NativeType 
result {};
             memcpy(&result, &ans, std::min(sizeof(result), sizeof(ans)));
             return result;
         } else {
diff --git a/be/src/vec/functions/function_bit.cpp 
b/be/src/vec/functions/function_bit.cpp
index 5d2f505f9ad..c8daa205635 100644
--- a/be/src/vec/functions/function_bit.cpp
+++ b/be/src/vec/functions/function_bit.cpp
@@ -142,7 +142,7 @@ private:
 template <PrimitiveType PType>
 struct BitAndImpl {
     static_assert(is_int(PType));
-    using Arg = typename PrimitiveTypeTraits<PType>::CppNativeType;
+    using Arg = typename PrimitiveTypeTraits<PType>::CppType;
     using DataType = typename PrimitiveTypeTraits<PType>::DataType;
     using ColumnType = typename PrimitiveTypeTraits<PType>::ColumnType;
     static constexpr auto name = "bitand";
@@ -154,7 +154,7 @@ struct BitAndImpl {
 template <PrimitiveType PType>
 struct BitOrImpl {
     static_assert(is_int(PType));
-    using Arg = typename PrimitiveTypeTraits<PType>::CppNativeType;
+    using Arg = typename PrimitiveTypeTraits<PType>::CppType;
     using DataType = typename PrimitiveTypeTraits<PType>::DataType;
     using ColumnType = typename PrimitiveTypeTraits<PType>::ColumnType;
     static constexpr auto name = "bitor";
@@ -166,7 +166,7 @@ struct BitOrImpl {
 template <PrimitiveType PType>
 struct BitXorImpl {
     static_assert(is_int(PType));
-    using Arg = typename PrimitiveTypeTraits<PType>::CppNativeType;
+    using Arg = typename PrimitiveTypeTraits<PType>::CppType;
     using DataType = typename PrimitiveTypeTraits<PType>::DataType;
     using ColumnType = typename PrimitiveTypeTraits<PType>::ColumnType;
     static constexpr auto name = "bitxor";
diff --git a/be/src/vec/functions/function_convert_tz.cpp 
b/be/src/vec/functions/function_convert_tz.cpp
index 8c81d3b7beb..48a33752568 100644
--- a/be/src/vec/functions/function_convert_tz.cpp
+++ b/be/src/vec/functions/function_convert_tz.cpp
@@ -67,7 +67,6 @@ class FunctionConvertTZ : public IFunction {
     constexpr static PrimitiveType PType = PrimitiveType::TYPE_DATETIMEV2;
     using DateValueType = PrimitiveTypeTraits<PType>::CppType;
     using ColumnType = PrimitiveTypeTraits<PType>::ColumnType;
-    using NativeType = PrimitiveTypeTraits<PType>::CppNativeType;
 
 public:
     static constexpr auto name = "convert_tz";
diff --git a/be/src/vec/functions/minus.cpp b/be/src/vec/functions/minus.cpp
index 4a03dc20a4a..591b8dd8f03 100644
--- a/be/src/vec/functions/minus.cpp
+++ b/be/src/vec/functions/minus.cpp
@@ -33,15 +33,15 @@ struct MinusDecimalImpl {
     static constexpr auto name = "subtract";
     static constexpr PrimitiveType PTypeA = TypeA;
     static constexpr PrimitiveType PTypeB = TypeA;
-    using ArgNativeTypeA = typename PrimitiveTypeTraits<TypeA>::CppNativeType;
-    using ArgNativeTypeB = typename PrimitiveTypeTraits<TypeB>::CppNativeType;
+    using ArgNativeTypeA = typename 
PrimitiveTypeTraits<TypeA>::CppType::NativeType;
+    using ArgNativeTypeB = typename 
PrimitiveTypeTraits<TypeB>::CppType::NativeType;
 
     template <PrimitiveType Result>
         requires(is_decimal(Result) && Result != TYPE_DECIMALV2)
-    static inline typename PrimitiveTypeTraits<Result>::CppNativeType 
apply(ArgNativeTypeA a,
-                                                                            
ArgNativeTypeB b) {
-        return static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(a) - b);
+    static inline typename PrimitiveTypeTraits<Result>::CppType::NativeType 
apply(
+            ArgNativeTypeA a, ArgNativeTypeB b) {
+        return static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(a) - b);
     }
 
     static inline DecimalV2Value apply(const DecimalV2Value& a, const 
DecimalV2Value& b) {
@@ -52,10 +52,10 @@ struct MinusDecimalImpl {
     template <PrimitiveType Result>
         requires(is_decimal(Result) && Result != TYPE_DECIMALV2)
     static inline bool apply(ArgNativeTypeA a, ArgNativeTypeB b,
-                             typename 
PrimitiveTypeTraits<Result>::CppNativeType& c) {
+                             typename 
PrimitiveTypeTraits<Result>::CppType::NativeType& c) {
         return common::sub_overflow(
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(a),
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(b), c);
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(a),
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(b), c);
     }
 };
 
diff --git a/be/src/vec/functions/modulo.cpp b/be/src/vec/functions/modulo.cpp
index 0f2eaf9aeaf..23a8ea95548 100644
--- a/be/src/vec/functions/modulo.cpp
+++ b/be/src/vec/functions/modulo.cpp
@@ -425,8 +425,8 @@ struct ModNumericImpl {
 template <PrimitiveType Type>
 struct ModuloNumericImpl {
     static constexpr auto name = "mod";
-    using ArgA = typename PrimitiveTypeTraits<Type>::CppNativeType;
-    using ArgB = typename PrimitiveTypeTraits<Type>::CppNativeType;
+    using ArgA = typename PrimitiveTypeTraits<Type>::CppType;
+    using ArgB = typename PrimitiveTypeTraits<Type>::CppType;
     using ColumnType = typename PrimitiveTypeTraits<Type>::ColumnType;
     using DataTypeA = typename PrimitiveTypeTraits<Type>::DataType;
     using DataTypeB = typename PrimitiveTypeTraits<Type>::DataType;
@@ -454,8 +454,8 @@ struct ModuloNumericImpl {
         }
     }
 
-    static inline typename PrimitiveTypeTraits<Type>::CppNativeType apply(ArgA 
a, ArgB b,
-                                                                          
UInt8& is_null) {
+    static inline typename PrimitiveTypeTraits<Type>::CppType apply(ArgA a, 
ArgB b,
+                                                                    UInt8& 
is_null) {
         is_null = b == 0;
         b += is_null;
 
@@ -470,8 +470,8 @@ struct ModuloNumericImpl {
 
 template <PrimitiveType Type>
 struct PModuloNumericImpl {
-    using ArgA = typename PrimitiveTypeTraits<Type>::CppNativeType;
-    using ArgB = typename PrimitiveTypeTraits<Type>::CppNativeType;
+    using ArgA = typename PrimitiveTypeTraits<Type>::CppType;
+    using ArgB = typename PrimitiveTypeTraits<Type>::CppType;
     using ColumnType = typename PrimitiveTypeTraits<Type>::ColumnType;
     using DataTypeA = typename PrimitiveTypeTraits<Type>::DataType;
     using DataTypeB = typename PrimitiveTypeTraits<Type>::DataType;
@@ -501,8 +501,8 @@ struct PModuloNumericImpl {
         }
     }
 
-    static inline typename PrimitiveTypeTraits<Type>::CppNativeType apply(ArgA 
a, ArgB b,
-                                                                          
UInt8& is_null) {
+    static inline typename PrimitiveTypeTraits<Type>::CppType apply(ArgA a, 
ArgB b,
+                                                                    UInt8& 
is_null) {
         is_null = b == 0;
         b += is_null;
 
@@ -531,8 +531,8 @@ struct ModuloDecimalImpl {
     static constexpr auto is_pmod = false;
     using ArgA = typename PrimitiveTypeTraits<TypeA>::CppType;
     using ArgB = typename PrimitiveTypeTraits<TypeB>::CppType;
-    using ArgNativeTypeA = typename PrimitiveTypeTraits<TypeA>::CppNativeType;
-    using ArgNativeTypeB = typename PrimitiveTypeTraits<TypeB>::CppNativeType;
+    using ArgNativeTypeA = typename 
PrimitiveTypeTraits<TypeA>::CppType::NativeType;
+    using ArgNativeTypeB = typename 
PrimitiveTypeTraits<TypeB>::CppType::NativeType;
     using DataTypeA = typename PrimitiveTypeTraits<TypeA>::DataType;
     using DataTypeB = typename PrimitiveTypeTraits<TypeB>::DataType;
     using ColumnTypeA = typename PrimitiveTypeTraits<TypeA>::ColumnType;
@@ -568,9 +568,8 @@ struct ModDecimalImpl {
 
     template <PrimitiveType ResultType>
         requires(is_decimal(ResultType) && ResultType != TYPE_DECIMALV2)
-    static inline typename PrimitiveTypeTraits<ResultType>::CppNativeType 
impl(ArgNativeTypeA a,
-                                                                               
ArgNativeTypeB b,
-                                                                               
UInt8& is_null) {
+    static inline typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType impl(
+            ArgNativeTypeA a, ArgNativeTypeB b, UInt8& is_null) {
         is_null = b == 0;
         b += is_null;
 
@@ -578,7 +577,8 @@ struct ModDecimalImpl {
         if constexpr (Impl::is_pmod) {
             return (a % b + b) % b;
         } else {
-            return static_cast<typename 
PrimitiveTypeTraits<ResultType>::CppNativeType>(a) % b;
+            return static_cast<typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType>(a) %
+                   b;
         }
     }
 
@@ -824,7 +824,7 @@ struct ModDecimalImpl {
 
     template <bool check_overflow_for_decimal, PrimitiveType ResultType>
         requires(is_decimal(ResultType))
-    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppNativeType apply(
+    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType apply(
             ArgNativeTypeA a, ArgNativeTypeB b, UInt8& is_null,
             const typename PrimitiveTypeTraits<ResultType>::CppType& 
max_result_number) {
         if constexpr (DataTypeA::PType == TYPE_DECIMALV2) {
@@ -861,7 +861,7 @@ struct ModDecimalImpl {
                     }
                 }
             }
-            typename PrimitiveTypeTraits<ResultType>::CppNativeType result {};
+            typename PrimitiveTypeTraits<ResultType>::CppType::NativeType 
result {};
             memcpy(&result, &ans, std::min(sizeof(result), sizeof(ans)));
             return result;
         } else {
diff --git a/be/src/vec/functions/multiply.cpp 
b/be/src/vec/functions/multiply.cpp
index f833c26683b..26b0d3f2f9d 100644
--- a/be/src/vec/functions/multiply.cpp
+++ b/be/src/vec/functions/multiply.cpp
@@ -52,8 +52,8 @@ struct MultiplyIntegralImpl {
                 std::make_shared<typename 
PrimitiveTypeTraits<Type>::DataType>()};
     }
 
-    NO_SANITIZE_UNDEFINED static inline typename 
PrimitiveTypeTraits<Type>::CppNativeType apply(
-            Arg a, Arg b) {
+    NO_SANITIZE_UNDEFINED static inline typename 
PrimitiveTypeTraits<Type>::CppType apply(Arg a,
+                                                                               
           Arg b) {
         return a * b;
     }
 
@@ -119,8 +119,8 @@ struct MultiplyDecimalImpl {
     using ArgB = typename PrimitiveTypeTraits<TypeB>::CppType;
     static constexpr PrimitiveType ArgAPType = TypeA;
     static constexpr PrimitiveType ArgBPType = TypeB;
-    using ArgNativeTypeA = typename PrimitiveTypeTraits<TypeA>::CppNativeType;
-    using ArgNativeTypeB = typename PrimitiveTypeTraits<TypeB>::CppNativeType;
+    using ArgNativeTypeA = typename 
PrimitiveTypeTraits<TypeA>::CppType::NativeType;
+    using ArgNativeTypeB = typename 
PrimitiveTypeTraits<TypeB>::CppType::NativeType;
     using DataTypeA = typename PrimitiveTypeTraits<TypeA>::DataType;
     using DataTypeB = typename PrimitiveTypeTraits<TypeB>::DataType;
     using ColumnTypeA = typename PrimitiveTypeTraits<TypeA>::ColumnType;
@@ -133,10 +133,10 @@ struct MultiplyDecimalImpl {
 
     template <PrimitiveType Result>
         requires(is_decimal(Result) && Result != TYPE_DECIMALV2)
-    static inline typename PrimitiveTypeTraits<Result>::CppNativeType 
apply(ArgNativeTypeA a,
-                                                                            
ArgNativeTypeB b) {
-        return static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(a) * b);
+    static inline typename PrimitiveTypeTraits<Result>::CppType::NativeType 
apply(
+            ArgNativeTypeA a, ArgNativeTypeB b) {
+        return static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(a) * b);
     }
 
     template <PrimitiveType Result = TYPE_DECIMALV2>
@@ -148,10 +148,10 @@ struct MultiplyDecimalImpl {
     template <PrimitiveType Result>
         requires(is_decimal(Result))
     static inline bool apply(ArgNativeTypeA a, ArgNativeTypeB b,
-                             typename 
PrimitiveTypeTraits<Result>::CppNativeType& c) {
+                             typename 
PrimitiveTypeTraits<Result>::CppType::NativeType& c) {
         return common::mul_overflow(
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(a),
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(b), c);
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(a),
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(b), c);
     }
 
     template <PrimitiveType ResultType>
@@ -430,12 +430,12 @@ struct MultiplyDecimalImpl {
 
     template <bool need_adjust_scale, bool check_overflow, PrimitiveType 
ResultType>
         requires(is_decimal(ResultType) && ResultType != TYPE_DECIMALV2)
-    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppNativeType apply(
+    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType apply(
             ArgNativeTypeA a, ArgNativeTypeB b, const DataTypeA& type_left,
             const DataTypeB& type_right, const DataTypeDecimal<ResultType>& 
type_result,
             const typename PrimitiveTypeTraits<ResultType>::CppType& 
max_result_number,
             const typename PrimitiveTypeTraits<ResultType>::CppType& 
scale_diff_multiplier) {
-        typename PrimitiveTypeTraits<ResultType>::CppNativeType res;
+        typename PrimitiveTypeTraits<ResultType>::CppType::NativeType res;
         if constexpr (check_overflow) {
             // TODO handle overflow gracefully
             if (UNLIKELY(apply<ResultType>(a, b, res))) {
@@ -512,7 +512,7 @@ struct MultiplyDecimalImpl {
 
     template <bool need_adjust_scale, bool check_overflow, PrimitiveType 
ResultType>
         requires(ResultType == TYPE_DECIMALV2)
-    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppNativeType apply(
+    static ALWAYS_INLINE typename 
PrimitiveTypeTraits<ResultType>::CppType::NativeType apply(
             ArgNativeTypeA a, ArgNativeTypeB b, const DataTypeA& type_left,
             const DataTypeB& type_right, const DataTypeDecimal<ResultType>& 
type_result,
             const typename PrimitiveTypeTraits<ResultType>::CppType& 
max_result_number,
diff --git a/be/src/vec/functions/plus.cpp b/be/src/vec/functions/plus.cpp
index 43d69334b3c..73e682cfa6a 100644
--- a/be/src/vec/functions/plus.cpp
+++ b/be/src/vec/functions/plus.cpp
@@ -42,15 +42,15 @@ struct PlusDecimalImpl {
     static constexpr auto name = "add";
     static constexpr PrimitiveType PTypeA = TypeA;
     static constexpr PrimitiveType PTypeB = TypeA;
-    using ArgNativeTypeA = typename PrimitiveTypeTraits<TypeA>::CppNativeType;
-    using ArgNativeTypeB = typename PrimitiveTypeTraits<TypeB>::CppNativeType;
+    using ArgNativeTypeA = typename 
PrimitiveTypeTraits<TypeA>::CppType::NativeType;
+    using ArgNativeTypeB = typename 
PrimitiveTypeTraits<TypeB>::CppType::NativeType;
 
     template <PrimitiveType Result>
         requires(is_decimal(Result) && Result != TYPE_DECIMALV2)
-    static inline typename PrimitiveTypeTraits<Result>::CppNativeType 
apply(ArgNativeTypeA a,
-                                                                            
ArgNativeTypeB b) {
-        return static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(a) + b);
+    static inline typename PrimitiveTypeTraits<Result>::CppType::NativeType 
apply(
+            ArgNativeTypeA a, ArgNativeTypeB b) {
+        return static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(a) + b);
     }
 
     static inline DecimalV2Value apply(const DecimalV2Value& a, const 
DecimalV2Value& b) {
@@ -62,10 +62,10 @@ struct PlusDecimalImpl {
         requires(is_decimal(Result) && Result != TYPE_DECIMALV2)
     NO_SANITIZE_UNDEFINED static inline bool apply(
             ArgNativeTypeA a, ArgNativeTypeB b,
-            typename PrimitiveTypeTraits<Result>::CppNativeType& c) {
+            typename PrimitiveTypeTraits<Result>::CppType::NativeType& c) {
         return common::add_overflow(
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(a),
-                static_cast<typename 
PrimitiveTypeTraits<Result>::CppNativeType>(b), c);
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(a),
+                static_cast<typename 
PrimitiveTypeTraits<Result>::CppType::NativeType>(b), c);
     }
 };
 
diff --git a/be/src/vec/functions/round.h b/be/src/vec/functions/round.h
index 276ed47e7d7..b27be64e7ed 100644
--- a/be/src/vec/functions/round.h
+++ b/be/src/vec/functions/round.h
@@ -74,12 +74,36 @@ enum class TieBreakingMode {
     Bankers, // use banker's rounding
 };
 
+template <PrimitiveType PT>
+struct RoundType {
+    using NativeType = typename PrimitiveTypeTraits<PT>::CppType;
+};
+
+template <>
+struct RoundType<TYPE_DECIMAL32> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL32>::CppType::NativeType;
+};
+template <>
+struct RoundType<TYPE_DECIMAL64> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL64>::CppType::NativeType;
+};
+template <>
+struct RoundType<TYPE_DECIMAL128I> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL128I>::CppType::NativeType;
+};
+template <>
+struct RoundType<TYPE_DECIMALV2> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMALV2>::CppType::NativeType;
+};
+template <>
+struct RoundType<TYPE_DECIMAL256> {
+    using NativeType = typename 
PrimitiveTypeTraits<TYPE_DECIMAL256>::CppType::NativeType;
+};
+
 template <PrimitiveType Type, RoundingMode rounding_mode, ScaleMode scale_mode,
           TieBreakingMode tie_breaking_mode, typename U>
 struct IntegerRoundingComputation {
-    using T =
-            std::conditional_t<is_decimal(Type), typename 
PrimitiveTypeTraits<Type>::CppNativeType,
-                               typename PrimitiveTypeTraits<Type>::CppType>;
+    using T = typename RoundType<Type>::NativeType;
     static const size_t data_count = 1;
 
     static size_t prepare(size_t scale) { return scale; }
diff --git a/be/src/vec/sink/vtablet_block_convertor.cpp 
b/be/src/vec/sink/vtablet_block_convertor.cpp
index a006ebaf490..883ea54165e 100644
--- a/be/src/vec/sink/vtablet_block_convertor.cpp
+++ b/be/src/vec/sink/vtablet_block_convertor.cpp
@@ -183,14 +183,14 @@ DecimalType 
OlapTableBlockConvertor::_get_decimalv3_min_or_max(const DataTypePtr
         return DecimalType(iter->second);
     }
 
-    typename DecimalType::NativeType value;
+    DecimalType value;
     if constexpr (IsMin) {
         value = 
vectorized::min_decimal_value<DecimalType::PType>(type->get_precision());
     } else {
         value = 
vectorized::max_decimal_value<DecimalType::PType>(type->get_precision());
     }
-    pmap->emplace(type->get_precision(), value);
-    return DecimalType(value);
+    pmap->emplace(type->get_precision(), value.value);
+    return value;
 }
 
 Status OlapTableBlockConvertor::_internal_validate_column(


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to