branch-2.1: [fix](agg) prevent core dump in ColumnArray::size_at when handling type mismatch in streaming_agg_serialize_to_column #50001 (#50095)

### What problem does this PR solve?

Cherry-picked from: #50001
This commit is contained in:
lw112
2025-04-17 09:30:06 +08:00
committed by GitHub
parent 41b5866c3e
commit c3a201dcbf
3 changed files with 35 additions and 1 deletions

View File

@ -782,7 +782,8 @@ public:
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);
auto& vec = col_null->get_nested_column();
vec.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();

View File

@ -254,3 +254,7 @@
-- !select --
[null, "0.0.0.123", "0.0.12.42", "0.119.130.67"] [null, "::855d", "::0.4.221.183", "::a:7429:d0d6:6e08:9f5f"]
-- !select --
corp001 [["tag3"], ["tag1", "tag2"]]
corp002 [["tag4", "tag5"]]

View File

@ -297,4 +297,33 @@ suite("array_agg") {
sql "DROP TABLE `test_array_agg_int`"
sql "DROP TABLE `test_array_agg_decimal`"
sql "DROP TABLE `test_array_agg_ip`"
sql """ drop table if exists test_user_tags;"""
sql """
CREATE TABLE test_user_tags (
k1 varchar(150) NULL,
k2 varchar(150) NULL,
k3 varchar(150) NULL,
k4 array<varchar(150)> NULL,
k5 array<varchar(150)> NULL,
k6 datetime NULL
) ENGINE=OLAP
UNIQUE KEY(k1, k2, k3)
DISTRIBUTED BY HASH(k2) BUCKETS 3
PROPERTIES ("replication_allocation" = "tag.location.default: 1");
"""
sql """
INSERT INTO test_user_tags VALUES
('corp001', 'wx001', 'vip', ['id1', 'id2'], ['tag1', 'tag2'], '2023-01-01 10:00:00'),
('corp001', 'wx001', 'level', ['id3'], ['tag3'], '2023-01-01 10:00:00'),
('corp002', 'wx002', 'vip', ['id4', 'id5'], ['tag4', 'tag5'], '2023-01-02 10:00:00');
"""
sql "SET spill_streaming_agg_mem_limit = 1024;"
sql "SET enable_agg_spill = true;"
qt_select """ SELECT k1,array_agg(k5) FROM test_user_tags group by k1 order by k1; """
sql "UNSET VARIABLE ALL;"
}