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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit a14fe09ff8a1027e4796111b3b8ea78291708259
Author: Jerry Hu <[email protected]>
AuthorDate: Tue Sep 12 18:21:33 2023 +0800

    [fix](agg) Add the unimplemented functions in AggregateFunctionOldSum. 
(#24211)
---
 .../aggregate_function_sum_old.h                   | 16 +++++++
 be/src/vec/aggregate_functions/helpers.h           | 54 ++++++++++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/be/src/vec/aggregate_functions/aggregate_function_sum_old.h 
b/be/src/vec/aggregate_functions/aggregate_function_sum_old.h
index a3b7280fd2..a63c3d911a 100644
--- a/be/src/vec/aggregate_functions/aggregate_function_sum_old.h
+++ b/be/src/vec/aggregate_functions/aggregate_function_sum_old.h
@@ -141,6 +141,22 @@ public:
         }
     }
 
+    void deserialize_and_merge_vec(const AggregateDataPtr* places, size_t 
offset,
+                                   AggregateDataPtr rhs, const ColumnString* 
column, Arena* arena,
+                                   const size_t num_rows) const override {
+        this->deserialize_from_column(rhs, *column, arena, num_rows);
+        DEFER({ this->destroy_vec(rhs, num_rows); });
+        this->merge_vec(places, offset, rhs, arena, num_rows);
+    }
+
+    void deserialize_and_merge_vec_selected(const AggregateDataPtr* places, 
size_t offset,
+                                            AggregateDataPtr rhs, const 
ColumnString* column,
+                                            Arena* arena, const size_t 
num_rows) const override {
+        this->deserialize_from_column(rhs, *column, arena, num_rows);
+        DEFER({ this->destroy_vec(rhs, num_rows); });
+        this->merge_vec_selected(places, offset, rhs, arena, num_rows);
+    }
+
     void deserialize_and_merge_from_column(AggregateDataPtr __restrict place, 
const IColumn& column,
                                            Arena* arena) const override {
         auto data = assert_cast<const ColVecResult&>(column).get_data().data();
diff --git a/be/src/vec/aggregate_functions/helpers.h 
b/be/src/vec/aggregate_functions/helpers.h
index 016f1fd2f0..f50524085c 100644
--- a/be/src/vec/aggregate_functions/helpers.h
+++ b/be/src/vec/aggregate_functions/helpers.h
@@ -47,6 +47,56 @@
     M(Decimal128)            \
     M(Decimal128I)
 
+/** If the serialized type is not the default type(string),
+ * aggregation function need to override these functions:
+ * 1. serialize_to_column
+ * 2. streaming_agg_serialize_to_column
+ * 3. deserialize_and_merge_vec
+ * 4. deserialize_and_merge_vec_selected
+ * 5. serialize_without_key_to_column
+ * 6. deserialize_and_merge_from_column
+ */
+#define CHECK_AGG_FUNCTION_SERIALIZED_TYPE(FunctionTemplate)                   
                    \
+    do {                                                                       
                    \
+        constexpr bool _is_new_serialized_type =                               
                    \
+                
!std::is_same_v<decltype(&FunctionTemplate::get_serialized_type),               
   \
+                                
decltype(&IAggregateFunction::get_serialized_type)>;               \
+        if constexpr (_is_new_serialized_type) {                               
                    \
+            
static_assert(!std::is_same_v<decltype(&FunctionTemplate::serialize_to_column), 
       \
+                                          decltype(&IAggregateFunctionHelper<  
                    \
+                                                   
FunctionTemplate>::serialize_to_column)>,       \
+                          "need to override serialize_to_column");             
                    \
+            static_assert(                                                     
                    \
+                    !std::is_same_v<                                           
                    \
+                            
decltype(&FunctionTemplate::streaming_agg_serialize_to_column),        \
+                            
decltype(&IAggregateFunction::streaming_agg_serialize_to_column)>,     \
+                    "need to override "                                        
                    \
+                    "streaming_agg_serialize_to_column");                      
                    \
+            
static_assert(!std::is_same_v<decltype(&FunctionTemplate::deserialize_and_merge_vec),
  \
+                                          decltype(&IAggregateFunctionHelper<  
                    \
+                                                   
FunctionTemplate>::deserialize_and_merge_vec)>, \
+                          "need to override deserialize_and_merge_vec");       
                    \
+            static_assert(                                                     
                    \
+                    !std::is_same_v<                                           
                    \
+                            
decltype(&FunctionTemplate::deserialize_and_merge_vec_selected),       \
+                            decltype(&IAggregateFunctionHelper<                
                    \
+                                     
FunctionTemplate>::deserialize_and_merge_vec_selected)>,      \
+                    "need to override "                                        
                    \
+                    "deserialize_and_merge_vec_selected");                     
                    \
+            static_assert(                                                     
                    \
+                    
!std::is_same_v<decltype(&FunctionTemplate::serialize_without_key_to_column),  \
+                                    decltype(&IAggregateFunctionHelper<        
                    \
+                                             
FunctionTemplate>::serialize_without_key_to_column)>, \
+                    "need to override serialize_without_key_to_column");       
                    \
+            static_assert(!std::is_same_v<                                     
                    \
+                                  
decltype(&FunctionTemplate::deserialize_and_merge_from_column),  \
+                                  decltype(&IAggregateFunctionHelper<          
                    \
+                                           
FunctionTemplate>::deserialize_and_merge_from_column)>, \
+                          "need to override "                                  
                    \
+                          "deserialize_and_merge_from_column");                
                    \
+        }                                                                      
                    \
+    } while (false)
+
 namespace doris::vectorized {
 
 struct creator_without_type {
@@ -57,6 +107,7 @@ struct creator_without_type {
     template <typename AggregateFunctionTemplate>
     static AggregateFunctionPtr creator(const std::string& name, const 
DataTypes& argument_types,
                                         const bool result_is_nullable) {
+        CHECK_AGG_FUNCTION_SERIALIZED_TYPE(AggregateFunctionTemplate);
         return create<AggregateFunctionTemplate>(argument_types, 
result_is_nullable);
     }
 
@@ -74,6 +125,8 @@ struct creator_without_type {
                     make_bool_variant(argument_types.size() > 1),
                     make_bool_variant(result_is_nullable));
         }
+
+        CHECK_AGG_FUNCTION_SERIALIZED_TYPE(AggregateFunctionTemplate);
         return AggregateFunctionPtr(result);
     }
 
@@ -85,6 +138,7 @@ struct creator_without_type {
                                                        TArgs&&... args) {
         IAggregateFunction* result(
                 new AggregateFunctionTemplate(std::forward<TArgs>(args)..., 
argument_types));
+        CHECK_AGG_FUNCTION_SERIALIZED_TYPE(AggregateFunctionTemplate);
         return AggregateFunctionPtr(result);
     }
 };


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

Reply via email to