@@ -63,12 +63,29 @@ class VAggCollectTest : public testing::Test {
6363
6464 template <typename DataType>
6565 void agg_collect_add_elements (AggregateFunctionPtr agg_function, AggregateDataPtr place,
66- size_t input_nums) {
66+ size_t input_nums, bool support_complex = false ) {
6767 using FieldType = typename DataType::FieldType;
68- auto type = std::make_shared<DataType>();
69- auto input_col = type->create_column ();
68+ MutableColumnPtr input_col;
69+ if (support_complex) {
70+ auto type =
71+ std::make_shared<DataTypeArray>(make_nullable (std::make_shared<DataType>()));
72+ input_col = type->create_column ();
73+ } else {
74+ auto type = std::make_shared<DataType>();
75+ input_col = type->create_column ();
76+ }
7077 for (size_t i = 0 ; i < input_nums; ++i) {
7178 for (size_t j = 0 ; j < _repeated_times; ++j) {
79+ if (support_complex) {
80+ if constexpr (std::is_same_v<DataType, DataTypeString>) {
81+ Array vec1 = {Field (String (" item0" + std::to_string (i))),
82+ Field (String (" item1" + std::to_string (i)))};
83+ input_col->insert (vec1);
84+ } else {
85+ input_col->insert_default ();
86+ }
87+ continue ;
88+ }
7289 if constexpr (std::is_same_v<DataType, DataTypeString>) {
7390 auto item = std::string (" item" ) + std::to_string (i);
7491 input_col->insert_data (item.c_str (), item.size ());
@@ -87,8 +104,13 @@ class VAggCollectTest : public testing::Test {
87104 }
88105
89106 template <typename DataType>
90- void test_agg_collect (const std::string& fn_name, size_t input_nums = 0 ) {
107+ void test_agg_collect (const std::string& fn_name, size_t input_nums = 0 ,
108+ bool support_complex = false ) {
91109 DataTypes data_types = {(DataTypePtr)std::make_shared<DataType>()};
110+ if (support_complex) {
111+ data_types = {
112+ (DataTypePtr)std::make_shared<DataTypeArray>(make_nullable (data_types[0 ]))};
113+ }
92114 LOG (INFO) << " test_agg_collect for " << fn_name << " (" << data_types[0 ]->get_name () << " )" ;
93115 AggregateFunctionSimpleFactory factory = AggregateFunctionSimpleFactory::instance ();
94116 auto agg_function = factory.get (fn_name, data_types, false , -1 );
@@ -98,7 +120,7 @@ class VAggCollectTest : public testing::Test {
98120 AggregateDataPtr place = memory.get ();
99121 agg_function->create (place);
100122
101- agg_collect_add_elements<DataType>(agg_function, place, input_nums);
123+ agg_collect_add_elements<DataType>(agg_function, place, input_nums, support_complex );
102124
103125 ColumnString buf;
104126 VectorBufferWriter buf_writer (buf);
@@ -111,7 +133,7 @@ class VAggCollectTest : public testing::Test {
111133 AggregateDataPtr place2 = memory2.get ();
112134 agg_function->create (place2);
113135
114- agg_collect_add_elements<DataType>(agg_function, place2, input_nums);
136+ agg_collect_add_elements<DataType>(agg_function, place2, input_nums, support_complex );
115137
116138 agg_function->merge (place, place2, &_agg_arena_pool);
117139 auto column_result = ColumnArray::create (data_types[0 ]->create_column ());
@@ -173,4 +195,15 @@ TEST_F(VAggCollectTest, test_with_data) {
173195 test_agg_collect<DataTypeString>(" collect_set" , 5 );
174196}
175197
198+ TEST_F (VAggCollectTest, test_complex_data_type) {
199+ test_agg_collect<DataTypeInt8>(" collect_list" , 7 , true );
200+ test_agg_collect<DataTypeInt128>(" array_agg" , 9 , true );
201+
202+ test_agg_collect<DataTypeDateTime>(" collect_list" , 5 , true );
203+ test_agg_collect<DataTypeDateTime>(" array_agg" , 6 , true );
204+
205+ test_agg_collect<DataTypeString>(" collect_list" , 10 , true );
206+ test_agg_collect<DataTypeString>(" array_agg" , 5 , true );
207+ }
208+
176209} // namespace doris::vectorized
0 commit comments