This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.1 by this push: new 1db0aef9b74 [feature](array_agg) support array_agg with param is array/map/struct… (#41651) 1db0aef9b74 is described below commit 1db0aef9b741e3d153677e305d520efcdd330d4d Author: amory <wangqian...@selectdb.com> AuthorDate: Thu Oct 10 17:54:54 2024 +0800 [feature](array_agg) support array_agg with param is array/map/struct… (#41651) … (#40697) this pr we support array_agg function support param with array map struct type ## Proposed changes Issue Number: close #xxx <!--Describe your changes.--> --- .../aggregate_function_collect.cpp | 30 ++-- .../aggregate_function_collect.h | 72 +++++++++- .../data/query_p0/aggregate/array_agg.out | 156 +++++++++++++++++++++ .../query_p0/aggregate/test_array_agg_complex.csv | 112 +++++++++++++++ .../suites/query_p0/aggregate/array_agg.groovy | 27 ++++ 5 files changed, 385 insertions(+), 12 deletions(-) diff --git a/be/src/vec/aggregate_functions/aggregate_function_collect.cpp b/be/src/vec/aggregate_functions/aggregate_function_collect.cpp index 2831f39aa30..4fcf09b59b3 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_collect.cpp +++ b/be/src/vec/aggregate_functions/aggregate_function_collect.cpp @@ -38,15 +38,18 @@ AggregateFunctionPtr do_create_agg_function_collect(bool distinct, const DataTyp } } - if (distinct) { - return creator_without_type::create<AggregateFunctionCollect< - AggregateFunctionCollectSetData<T, HasLimit>, HasLimit, std::false_type>>( - argument_types, result_is_nullable); - } else { - return creator_without_type::create<AggregateFunctionCollect< - AggregateFunctionCollectListData<T, HasLimit>, HasLimit, std::false_type>>( - argument_types, result_is_nullable); + if constexpr (!std::is_same_v<T, void>) { + if (distinct) { + return creator_without_type::create<AggregateFunctionCollect< + AggregateFunctionCollectSetData<T, HasLimit>, HasLimit, std::false_type>>( + argument_types, result_is_nullable); + } else { + return creator_without_type::create<AggregateFunctionCollect< + AggregateFunctionCollectListData<T, HasLimit>, HasLimit, std::false_type>>( + argument_types, result_is_nullable); + } } + return nullptr; } template <typename HasLimit, typename ShowNull> @@ -69,15 +72,21 @@ AggregateFunctionPtr create_aggregate_function_collect_impl(const std::string& n if (which.is_date_or_datetime()) { return do_create_agg_function_collect<Int64, HasLimit, ShowNull>(distinct, argument_types, result_is_nullable); - } else if (which.is_date_v2()) { + } else if (which.is_date_v2() || which.is_ipv4()) { return do_create_agg_function_collect<UInt32, HasLimit, ShowNull>(distinct, argument_types, result_is_nullable); - } else if (which.is_date_time_v2()) { + } else if (which.is_date_time_v2() || which.is_ipv6()) { return do_create_agg_function_collect<UInt64, HasLimit, ShowNull>(distinct, argument_types, result_is_nullable); } else if (which.is_string()) { return do_create_agg_function_collect<StringRef, HasLimit, ShowNull>( distinct, argument_types, result_is_nullable); + } else { + // generic serialize which will not use specializations, ShowNull::value always means array_agg + if constexpr (ShowNull::value) { + return do_create_agg_function_collect<void, HasLimit, ShowNull>( + distinct, argument_types, result_is_nullable); + } } LOG(WARNING) << fmt::format("unsupported input type {} for aggregate function {}", @@ -107,6 +116,7 @@ AggregateFunctionPtr create_aggregate_function_collect(const std::string& name, } void register_aggregate_function_collect_list(AggregateFunctionSimpleFactory& factory) { + // notice: array_agg only differs from collect_list in that array_agg will show null elements in array factory.register_function_both("collect_list", create_aggregate_function_collect); factory.register_function_both("collect_set", create_aggregate_function_collect); factory.register_function_both("array_agg", create_aggregate_function_collect); diff --git a/be/src/vec/aggregate_functions/aggregate_function_collect.h b/be/src/vec/aggregate_functions/aggregate_function_collect.h index dcbab056bf0..95193d2039c 100644 --- a/be/src/vec/aggregate_functions/aggregate_function_collect.h +++ b/be/src/vec/aggregate_functions/aggregate_function_collect.h @@ -505,6 +505,71 @@ struct AggregateFunctionArrayAggData<StringRef> { } }; +template <> +struct AggregateFunctionArrayAggData<void> { + using ElementType = StringRef; + using Self = AggregateFunctionArrayAggData<void>; + MutableColumnPtr column_data; + + AggregateFunctionArrayAggData() {} + + AggregateFunctionArrayAggData(const DataTypes& argument_types) { + DataTypePtr column_type = argument_types[0]; + column_data = column_type->create_column(); + } + + void add(const IColumn& column, size_t row_num) { column_data->insert_from(column, row_num); } + + void deserialize_and_merge(const IColumn& column, size_t row_num) { + auto& to_arr = assert_cast<const ColumnArray&>(column); + auto& to_nested_col = to_arr.get_data(); + auto start = to_arr.get_offsets()[row_num - 1]; + auto end = start + to_arr.get_offsets()[row_num] - to_arr.get_offsets()[row_num - 1]; + for (auto i = start; i < end; ++i) { + column_data->insert_from(to_nested_col, i); + } + } + + void reset() { column_data->clear(); } + + void insert_result_into(IColumn& to) const { + auto& to_arr = assert_cast<ColumnArray&>(to); + auto& to_nested_col = to_arr.get_data(); + size_t num_rows = column_data->size(); + for (size_t i = 0; i < num_rows; ++i) { + to_nested_col.insert_from(*column_data, i); + } + to_arr.get_offsets().push_back(to_nested_col.size()); + } + + void write(BufferWritable& buf) const { + const size_t size = column_data->size(); + write_binary(size, buf); + for (size_t i = 0; i < size; i++) { + write_string_binary(column_data->get_data_at(i), buf); + } + } + + void read(BufferReadable& buf) { + size_t size = 0; + read_binary(size, buf); + column_data->reserve(size); + + StringRef s; + for (size_t i = 0; i < size; i++) { + read_string_binary(s, buf); + column_data->insert_data(s.data, s.size); + } + } + + void merge(const Self& rhs) { + const auto size = rhs.column_data->size(); + for (size_t i = 0; i < size; i++) { + column_data->insert_from(*rhs.column_data, i); + } + } +}; + //ShowNull is just used to support array_agg because array_agg needs to display NULL //todo: Supports order by sorting for array_agg template <typename Data, typename HasLimit, typename ShowNull> @@ -539,7 +604,8 @@ public: void create(AggregateDataPtr __restrict place) const override { if constexpr (ShowNull::value) { - if constexpr (IsDecimalNumber<typename Data::ElementType>) { + if constexpr (IsDecimalNumber<typename Data::ElementType> || + std::is_same_v<Data, AggregateFunctionArrayAggData<void>>) { new (place) Data(argument_types); } else { new (place) Data(); @@ -708,11 +774,13 @@ public: for (size_t i = 0; i < num_rows; ++i) { col_null->get_null_map_data().push_back(col_src.get_null_map_data()[i]); - if constexpr (std::is_same_v<StringRef, typename Data::ElementType>) { + if constexpr (std::is_same_v<Data, AggregateFunctionArrayAggData<StringRef>>) { auto& vec = assert_cast<ColumnString&>(col_null->get_nested_column()); const auto& vec_src = assert_cast<const ColumnString&>(col_src.get_nested_column()); vec.insert_from(vec_src, i); + } else if constexpr (std::is_same_v<Data, AggregateFunctionArrayAggData<void>>) { + to_nested_col.insert_from(col_src.get_nested_column(), i); } else { using ColVecType = ColumnVectorOrDecimal<typename Data::ElementType>; auto& vec = assert_cast<ColVecType&>(col_null->get_nested_column()).get_data(); diff --git a/regression-test/data/query_p0/aggregate/array_agg.out b/regression-test/data/query_p0/aggregate/array_agg.out index 5f019f755e0..1fe44df3a14 100644 --- a/regression-test/data/query_p0/aggregate/array_agg.out +++ b/regression-test/data/query_p0/aggregate/array_agg.out @@ -95,3 +95,159 @@ 3 3 3 3 +-- !sql_array_agg_array -- +1 [["plum", "banana", "apple"], ["grape", "banana", null, "plum", "cherry"], ["apple", "banana", "kiwi", null], ["apple", "banana", "cherry", "kiwi", null], ["cherry", null], null] +10 [null, ["apple", "banana", null, "cherry", "grape"], ["cherry", "berry", null], ["peach"]] +11 [["grape", "apple", "kiwi"], null, null, null] +12 [["melon", "papaya", "kiwi"], ["plum", null, "kiwi", "banana"], ["plum", null, "mango"], ["plum", null]] +13 [["apple", null], null, ["peach", "cherry", "papaya", "kiwi", null], ["plum", null]] +14 [["orange", "mango", "plum"], ["apple", "melon"], ["orange", "grape", null], ["orange", "banana", null]] +15 [null, ["banana", "peach", "plum", null], null, ["strawberry", null]] +16 [["peach", "kiwi", null, "berry"], null, ["plum", "grape", null], ["kiwi", null]] +17 [["banana", "plum", null], ["papaya"], null, ["apple", "kiwi", null, "papaya"]] +18 [["apple", null], null, ["apple", "mango", null], null] +19 [["kiwi", "mango", null], ["pear", "grape"], ["cherry", null, "plum"], ["banana", "mango", "cherry"]] +2 [null, ["apple", null, "banana"], ["orange", "grape", null], null] +20 [["grape", null], ["kiwi", null], ["kiwi", "plum", "orange", null], ["papaya", "orange", "kiwi", null]] +21 [["kiwi", null]] +22 [["orange", "peach", null, "kiwi"]] +23 [["berry", "grape", null]] +24 [null] +25 [["mango", "plum", "apple", null]] +26 [["banana", null]] +27 [["orange", "kiwi", "plum", null]] +28 [null] +29 [["apple", null, "grape", "peach"]] +3 [["mango", null], ["orange"], ["apple", "kiwi", "papaya"], ["plum", "peach", null]] +30 [["kiwi", "banana", null]] +31 [["cherry", "berry", null, "plum"]] +32 [null] +33 [["apple", null, "kiwi", "orange"]] +34 [["grape", "plum", null]] +35 [["banana", null]] +36 [["kiwi", "orange", "plum", null]] +37 [null] +38 [["apple", null]] +39 [["plum", "grape", null]] +4 [["mango", null, "orange", "plum", "berry", "kiwi"], ["orange", "grape", "mango", "berry"], ["plum", "kiwi", null, "peach", "berry"], null] +40 [["banana", "kiwi", "peach", null]] +41 [["grape", null, "plum"]] +42 [["orange", "kiwi", "peach", null]] +43 [null] +44 [["apple", "banana", null]] +45 [["grape", null]] +46 [["plum", "kiwi", null, "orange"]] +47 [null] +48 [["mango", null]] +49 [["kiwi", "plum", "banana", null]] +5 [["peach", "melon", null], ["apple", null, "kiwi"], ["grape", "kiwi", null], null] +50 [null] +6 [null, null, ["cherry", "apple", null, "plum"], null] +7 [["papaya", "cherry", "apple", null], ["melon"], ["melon", null, "papaya", "grape", "kiwi", "berry", null], ["orange", "grape", "kiwi"]] +8 [["plum", "peach", null, "orange"], ["banana", null], ["berry", "cherry"], ["banana", "mango", null]] +9 [["orange", "kiwi", "berry", null, "plum"], ["apple", "kiwi", "plum", null, "mango"], ["kiwi", null], null] + +-- !sql_array_agg_map -- +1 [{"key5":null}, {"key2":15, "key3":8}, {"key1":10, "key2":5}, {"key1":10, "key2":20}, {"key2":null}, null] +10 [{"key3":5, "key4":null}, {"key1":null, "key6":9}, {"key2":10, "key7":null}, {"key1":10}] +11 [{"key1":9}, {"key4":5, "key5":null}, {"key1":3, "key5":null}, {"key4":null}] +12 [null, {"key4":25}, {"key2":20, "key3":null}, {"key1":null, "key2":5}] +13 [{"key2":null, "key3":7}, null, null, {"key3":null, "key5":10}] +14 [{"key6":5}, {"key5":15, "key6":25}, {"key1":3, "key6":8}, {"key4":3, "key5":null}] +15 [{"key1":18, "key6":22}, {"key2":4}, {"key3":null}, null] +16 [{"key2":20}, {"key2":2}, {"key2":8, "key3":null}, {"key7":7, "key3":null}] +17 [{"key4":8}, {"key6":9, "key7":null}, {"key1":10, "key4":14}, {"key7":null}] +18 [{"key1":11}, {"key1":10, "key2":null}, {"key2":2}, {"key2":null, "key5":10}] +19 [{"key7":9}, {"key1":1, "key2":2, "key3":3}, {"key1":null, "key7":6}, {"key3":7, "key4":null}] +2 [{"key1":null, "key5":25}, {"key1":10, "key2":null, "key3":20}, {"key2":null, "key3":7}, {"key3":null}] +20 [{"key1":null, "key3":6}, {"key1":1, "key9":6}, {"key1":14}, {"key5":3, "key7":null}] +21 [{"key1":10, "key6":2}] +22 [{"key3":null}] +23 [{"key1":8}] +24 [{"key2":15, "key4":null}] +25 [{"key7":18}] +26 [{"key3":12}] +27 [{"key5":10}] +28 [{"key1":14}] +29 [{"key2":4, "key4":null}] +3 [{"key1":12}, {"key1":5}, {"key3":null}, {"key1":5, "key4":null}] +30 [{"key6":6}] +31 [{"key3":null}] +32 [{"key2":9, "key7":null}] +33 [{"key1":7}] +34 [{"key4":20}] +35 [{"key1":12, "key5":null}] +36 [{"key3":11}] +37 [{"key1":null}] +38 [{"key2":3, "key6":9}] +39 [{"key5":8}] +4 [{"key2":30}, null, {"key4":15}, {"key3":7, "key4":null}] +40 [{"key1":15}] +41 [{"key3":7}] +42 [{"key4":5}] +43 [{"key1":2, "key7":null}] +44 [{"key2":14}] +45 [{"key4":12}] +46 [{"key6":10}] +47 [{"key2":null}] +48 [{"key5":9}] +49 [{"key1":13}] +5 [{"key1":10}, {"key1":7, "key2":8}, null, {"key2":8, "key5":null}] +50 [{"key7":8}] +6 [{"key4":7, "key6":null}, {"key1":1, "key2":2, "key3":null, "key4":4}, {"key3":null, "key6":12}, {"key2":null, "key3":25}] +7 [{"key1":12, "key3":6}, null, {"key4":15, "key5":null}, {"key1":5}] +8 [{"key1":6, "key7":12}, {"key2":9}, {"key1":null, "key5":50}, null] +9 [{"key2":null, "key5":40}, null, {"key2":14, "key5":7}, {"key1":10, "key2":20, "key3":30, "key4":40, "key5":50, "key6":60, "key7":null}] + +-- !sql_array_agg_struct -- +1 [{"id":1}, {"id":1}, {"id":1}, {"id":1}, {"id":1}, null] +10 [{"id":10}, {"id":10}, {"id":10}, {"id":null}] +11 [{"id":11}, {"id":11}, {"id":11}, {"id":null}] +12 [{"id":12}, {"id":12}, {"id":12}, {"id":null}] +13 [{"id":13}, {"id":13}, {"id":13}, {"id":null}] +14 [{"id":14}, {"id":null}, {"id":14}, {"id":null}] +15 [{"id":15}, {"id":null}, {"id":15}, {"id":null}] +16 [{"id":16}, {"id":16}, {"id":16}, {"id":16}] +17 [{"id":17}, {"id":17}, {"id":17}, {"id":17}] +18 [{"id":18}, {"id":null}, {"id":18}, {"id":18}] +19 [{"id":19}, {"id":null}, {"id":19}, {"id":19}] +2 [{"id":2}, {"id":null}, {"id":2}, {"id":2}] +20 [{"id":20}, {"id":20}, {"id":null}, {"id":null}] +21 [{"id":21}] +22 [{"id":22}] +23 [{"id":23}] +24 [{"id":24}] +25 [{"id":25}] +26 [{"id":26}] +27 [{"id":27}] +28 [{"id":28}] +29 [{"id":29}] +3 [{"id":3}, {"id":3}, {"id":3}, {"id":3}] +30 [{"id":30}] +31 [{"id":31}] +32 [{"id":32}] +33 [{"id":33}] +34 [{"id":34}] +35 [{"id":35}] +36 [{"id":36}] +37 [{"id":37}] +38 [{"id":38}] +39 [{"id":39}] +4 [{"id":null}, {"id":4}, {"id":4}, {"id":4}] +40 [{"id":40}] +41 [{"id":41}] +42 [{"id":42}] +43 [{"id":43}] +44 [{"id":44}] +45 [{"id":45}] +46 [{"id":46}] +47 [{"id":47}] +48 [{"id":48}] +49 [{"id":49}] +5 [{"id":5}, {"id":null}, {"id":5}, {"id":5}] +50 [{"id":50}] +6 [{"id":6}, {"id":6}, {"id":6}, {"id":6}] +7 [{"id":null}, {"id":null}, {"id":null}, {"id":7}] +8 [{"id":8}, {"id":8}, {"id":8}, {"id":8}] +9 [{"id":9}, {"id":9}, {"id":9}, {"id":9}] + diff --git a/regression-test/data/query_p0/aggregate/test_array_agg_complex.csv b/regression-test/data/query_p0/aggregate/test_array_agg_complex.csv new file mode 100644 index 00000000000..920e2d80280 --- /dev/null +++ b/regression-test/data/query_p0/aggregate/test_array_agg_complex.csv @@ -0,0 +1,112 @@ +1 \N \N \N +1 ["cherry", null] {"key2":null} {"id": 1} +1 ["apple", "banana", "cherry", "kiwi", null] {"key1":10, "key2":20} {"id": 1} +1 ["apple", "banana", "kiwi", null] {"key1":10, "key2":5} {"id": 1} +1 ["grape", "banana", null, "plum", "cherry"] {"key2":15, "key3":8} {"id": 1} +1 ["plum", "banana", "apple"] {"key5":null} {"id": 1} +2 \N {"key3":null} {"id": 2} +2 ["orange", "grape", null] {"key2":null, "key3":7} {"id": 2} +2 ["apple", null, "banana"] {"key1":10, "key2":null, "key3":20} {"id": null} +2 \N {"key1":null, "key5":25} {"id": 2} +3 ["plum", "peach", null] {"key1":5, "key4":null} {"id": 3} +3 ["apple", "kiwi", "papaya"] {"key3":null} {"id": 3} +3 ["orange"] {"key1":5} {"id": 3} +3 ["mango", null] {"key1":12} {"id": 3} +4 \N {"key3":7, "key4":null} {"id": 4} +4 ["plum", "kiwi", null, "peach", "berry"] {"key4":15} {"id": 4} +4 ["orange", "grape", "mango", "berry"] \N {"id": 4} +4 ["mango", null, "orange", "plum", "berry", "kiwi"] {"key2":30} {"id": null} +5 \N {"key2":8, "key5":null} {"id": 5} +5 ["grape", "kiwi", null] \N {"id": 5} +5 ["apple", null, "kiwi"] {"key1":7, "key2":8} {"id": null} +5 ["peach", "melon", null] {"key1":10} {"id": 5} +6 \N {"key2":null, "key3":25} {"id": 6} +6 ["cherry", "apple", null, "plum"] {"key3":null, "key6":12} {"id": 6} +6 \N {"key1":1, "key2":2, "key3":null, "key4":4} {"id": 6} +6 \N {"key4":7, "key6":null} {"id": 6} +7 ["orange", "grape", "kiwi"] {"key1":5} {"id": 7} +7 ["melon", null, "papaya", "grape", "kiwi", "berry", null] {"key4":15, "key5":null} {"id": null} +7 ["melon"] \N {"id": null} +7 ["papaya", "cherry", "apple", null] {"key1":12, "key3":6} {"id": null} +8 ["banana", "mango", null] \N {"id": 8} +8 ["berry", "cherry"] {"key1":null, "key5":50} {"id": 8} +8 ["banana", null] {"key2":9} {"id": 8} +8 ["plum", "peach", null, "orange"] {"key1":6, "key7":12} {"id": 8} +9 \N {"key1":10, "key2":20, "key3":30, "key4":40, "key5":50, "key6":60, "key7":null} {"id": 9} +9 ["kiwi", null] {"key2":14, "key5":7} {"id": 9} +9 ["apple", "kiwi", "plum", null, "mango"] \N {"id": 9} +9 ["orange", "kiwi", "berry", null, "plum"] {"key2":null, "key5":40} {"id": 9} +10 ["peach"] {"key1":10} {"id": null} +10 ["cherry", "berry", null] {"key2":10, "key7":null} {"id": 10} +10 ["apple", "banana", null, "cherry", "grape"] {"key1":null, "key6":9} {"id": 10} +10 \N {"key3":5, "key4":null} {"id": 10} +11 \N {"key4":null} {"id": null} +11 \N {"key1":3, "key5":null} {"id": 11} +11 \N {"key4":5, "key5":null} {"id": 11} +11 ["grape", "apple", "kiwi"] {"key1":9} {"id": 11} +12 ["plum", null] {"key1":null, "key2":5} {"id": null} +12 ["plum", null, "mango"] {"key2":20, "key3":null} {"id": 12} +12 ["plum", null, "kiwi", "banana"] {"key4":25} {"id": 12} +12 ["melon", "papaya", "kiwi"] \N {"id": 12} +13 ["plum", null] {"key3":null, "key5":10} {"id": null} +13 ["peach", "cherry", "papaya", "kiwi", null] \N {"id": 13} +13 \N \N {"id": 13} +13 ["apple", null] {"key2":null, "key3":7} {"id": 13} +14 ["orange", "banana", null] {"key4":3, "key5":null} {"id": null} +14 ["orange", "grape", null] {"key1":3, "key6":8} {"id": 14} +14 ["apple", "melon"] {"key5":15, "key6":25} {"id": null} +14 ["orange", "mango", "plum"] {"key6":5} {"id": 14} +15 ["strawberry", null] \N {"id": null} +15 \N {"key3":null} {"id": 15} +15 ["banana", "peach", "plum", null] {"key2":4} {"id": null} +15 \N {"key1":18, "key6":22} {"id": 15} +16 ["kiwi", null] {"key7":7, "key3":null} {"id": 16} +16 ["plum", "grape", null] {"key2":8, "key3":null} {"id": 16} +16 \N {"key2":2} {"id": 16} +16 ["peach", "kiwi", null, "berry"] {"key2":20} {"id": 16} +17 ["apple", "kiwi", null, "papaya"] {"key7":null} {"id": 17} +17 \N {"key1":10, "key4":14} {"id": 17} +17 ["papaya"] {"key6":9, "key7":null} {"id": 17} +17 ["banana", "plum", null] {"key4":8} {"id": 17} +18 \N {"key2":null, "key5":10} {"id": 18} +18 ["apple", "mango", null] {"key2":2} {"id": 18} +18 \N {"key1":10, "key2":null} {"id": null} +18 ["apple", null] {"key1":11} {"id": 18} +19 ["banana", "mango", "cherry"] {"key3":7, "key4":null} {"id": 19} +19 ["cherry", null, "plum"] {"key1":null, "key7":6} {"id": 19} +19 ["pear", "grape"] {"key1":1, "key2":2, "key3":3} {"id": null} +19 ["kiwi", "mango", null] {"key7":9} {"id": 19} +20 ["papaya", "orange", "kiwi", null] {"key5":3, "key7":null} {"id": null} +20 ["kiwi", "plum", "orange", null] {"key1":14} {"id": null} +20 ["kiwi", null] {"key1":1, "key9":6} {"id": 20} +20 ["grape", null] {"key1":null, "key3":6} {"id": 20} +21 ["kiwi", null] {"key1":10, "key6":2} {"id": 21} +22 ["orange", "peach", null, "kiwi"] {"key3":null} {"id": 22} +23 ["berry", "grape", null] {"key1":8} {"id": 23} +24 \N {"key2":15, "key4":null} {"id": 24} +25 ["mango", "plum", "apple", null] {"key7":18} {"id": 25} +26 ["banana", null] {"key3":12} {"id": 26} +27 ["orange", "kiwi", "plum", null] {"key5":10} {"id": 27} +28 \N {"key1":14} {"id": 28} +29 ["apple", null, "grape", "peach"] {"key2":4, "key4":null} {"id": 29} +30 ["kiwi", "banana", null] {"key6":6} {"id": 30} +31 ["cherry", "berry", null, "plum"] {"key3":null} {"id": 31} +32 \N {"key2":9, "key7":null} {"id": 32} +33 ["apple", null, "kiwi", "orange"] {"key1":7} {"id": 33} +34 ["grape", "plum", null] {"key4":20} {"id": 34} +35 ["banana", null] {"key1":12, "key5":null} {"id": 35} +36 ["kiwi", "orange", "plum", null] {"key3":11} {"id": 36} +37 \N {"key1":null} {"id": 37} +38 ["apple", null] {"key2":3, "key6":9} {"id": 38} +39 ["plum", "grape", null] {"key5":8} {"id": 39} +40 ["banana", "kiwi", "peach", null] {"key1":15} {"id": 40} +41 ["grape", null, "plum"] {"key3":7} {"id": 41} +42 ["orange", "kiwi", "peach", null] {"key4":5} {"id": 42} +43 \N {"key1":2, "key7":null} {"id": 43} +44 ["apple", "banana", null] {"key2":14} {"id": 44} +45 ["grape", null] {"key4":12} {"id": 45} +46 ["plum", "kiwi", null, "orange"] {"key6":10} {"id": 46} +47 \N {"key2":null} {"id": 47} +48 ["mango", null] {"key5":9} {"id": 48} +49 ["kiwi", "plum", "banana", null] {"key1":13} {"id": 49} +50 \N {"key7":8} {"id": 50} diff --git a/regression-test/suites/query_p0/aggregate/array_agg.groovy b/regression-test/suites/query_p0/aggregate/array_agg.groovy index 1484125d0da..217285b572c 100644 --- a/regression-test/suites/query_p0/aggregate/array_agg.groovy +++ b/regression-test/suites/query_p0/aggregate/array_agg.groovy @@ -20,6 +20,8 @@ suite("array_agg") { sql "DROP TABLE IF EXISTS `test_array_agg1`;" sql "DROP TABLE IF EXISTS `test_array_agg_int`;" sql "DROP TABLE IF EXISTS `test_array_agg_decimal`;" + sql "DROP TABLE IF EXISTS `test_array_agg_complex`;" + sql """ CREATE TABLE `test_array_agg` ( `id` int(11) NOT NULL, @@ -249,6 +251,31 @@ suite("array_agg") { SELECT count(value_field), size(array_agg(label_name)) FROM `test_array_agg` GROUP BY value_field order by value_field; """ + // only support nereids + sql "SET enable_nereids_planner=true;" + sql "SET enable_fallback_to_original_planner=false;" + sql """ CREATE TABLE IF NOT EXISTS test_array_agg_complex (id int, kastr array<string>, km map<string, int>, ks STRUCT<id: int>) engine=olap + DISTRIBUTED BY HASH(`id`) BUCKETS 4 + properties("replication_num" = "1") """ + streamLoad { + table "test_array_agg_complex" + file "test_array_agg_complex.csv" + time 60000 + + check { result, exception, startTime, endTime -> + if (exception != null) { + throw exception + } + log.info("Stream load result: ${result}".toString()) + def json = parseJson(result) + assertEquals(112, json.NumberTotalRows) + assertEquals(112, json.NumberLoadedRows) + } + } + + order_qt_sql_array_agg_array """ SELECT id, array_agg(kastr) FROM test_array_agg_complex GROUP BY id ORDER BY id """ + order_qt_sql_array_agg_map """ SELECT id, array_agg(km) FROM test_array_agg_complex GROUP BY id ORDER BY id """ + order_qt_sql_array_agg_struct """ SELECT id, array_agg(ks) FROM test_array_agg_complex GROUP BY id ORDER BY id """ sql "DROP TABLE `test_array_agg`" sql "DROP TABLE `test_array_agg1`" --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org