This is an automated email from the ASF dual-hosted git repository. panxiaolei 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 36216f0925 [Bug](Agg-State) fix coredump when state combinator input const column (#20510) 36216f0925 is described below commit 36216f0925a3bbc6a70dbae6a4eb2741e18db8b9 Author: Pxl <pxl...@qq.com> AuthorDate: Wed Jun 7 11:28:55 2023 +0800 [Bug](Agg-State) fix coredump when state combinator input const column (#20510) fix coredump when state combinator input const column --- be/src/vec/functions/function_agg_state.h | 4 +- .../data/datatype_p0/agg_state/test_agg_state.out | 45 ++++++++++++++ .../datatype_p0/agg_state/test_agg_state.groovy | 70 ++++++++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/be/src/vec/functions/function_agg_state.h b/be/src/vec/functions/function_agg_state.h index 1473fe9d34..4340fe31d9 100644 --- a/be/src/vec/functions/function_agg_state.h +++ b/be/src/vec/functions/function_agg_state.h @@ -70,7 +70,9 @@ public: for (size_t i = 0; i < arguments.size(); i++) { DataTypePtr signature = assert_cast<const DataTypeAggState*>(_return_type.get())->get_sub_types()[i]; - ColumnPtr column = block.get_by_position(arguments[i]).column; + ColumnPtr column = + block.get_by_position(arguments[i]).column->convert_to_full_column_if_const(); + save_columns.push_back(column); if (!signature->is_nullable() && column->is_nullable()) { return Status::InternalError( diff --git a/regression-test/data/datatype_p0/agg_state/test_agg_state.out b/regression-test/data/datatype_p0/agg_state/test_agg_state.out new file mode 100644 index 0000000000..5f6598304b --- /dev/null +++ b/regression-test/data/datatype_p0/agg_state/test_agg_state.out @@ -0,0 +1,45 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sum -- +6 + +-- !avg -- +2.0 + +-- !max_by -- +2 1 + +-- !sum_const -- +3 + +-- !sum_null -- +\N + +-- !length1 -- +1 11 + +-- !group1 -- +1 1 + +-- !merge1 -- +1 + +-- !length2 -- +1 11 +2 11 +3 11 +4 11 + +-- !group2 -- +1 1 +2 1 +3 2 +4 3 + +-- !merge2 -- +3 + +-- !union -- +3 + +-- !max_by_null -- +\N \N diff --git a/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy b/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy new file mode 100644 index 0000000000..829bb84cd3 --- /dev/null +++ b/regression-test/suites/datatype_p0/agg_state/test_agg_state.groovy @@ -0,0 +1,70 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_agg_state") { + sql """ DROP TABLE IF EXISTS d_table; """ + sql """ + create table d_table( + k1 int null, + k2 int not null, + k3 bigint null, + k4 varchar(100) null + ) + duplicate key (k1,k2,k3) + distributed BY hash(k1) buckets 3 + properties("replication_num" = "1"); + """ + + sql "insert into d_table select 1,1,1,'a';" + sql "insert into d_table select 2,2,2,'b';" + sql "insert into d_table select 3,3,null,'c';" + + qt_sum """ select sum_merge(sum_state(k1)) from d_table; """ + qt_avg """ select avg_merge(avg_state(k1)) from d_table; """ + qt_max_by """ select max_by_merge(max_by_state(k1,k3)),min_by_merge(min_by_state(k1,k3)) from d_table; """ + + qt_sum_const """ select sum_merge(sum_state(1)) from d_table; """ + qt_sum_null """ select sum_merge(sum_state(null)) from d_table; """ + + sql """ DROP TABLE IF EXISTS a_table; """ + sql """ + create table a_table( + k1 int null, + k2 agg_state max_by(int not null,int) + ) + aggregate key (k1) + distributed BY hash(k1) buckets 3 + properties("replication_num" = "1","disable_auto_compaction" = "true"); + """ + + sql "insert into a_table select 1,max_by_state(1,3);" + sql "insert into a_table select 1,max_by_state(2,2);" + sql "insert into a_table select 1,max_by_state(3,1);" + + qt_length1 """select k1,length(k2) from a_table order by k1;""" + qt_group1 """select k1,max_by_merge(k2) from a_table group by k1 order by k1;""" + qt_merge1 """select max_by_merge(k2) from a_table;""" + + sql "insert into a_table select k1+1, max_by_state(k2,k1) from d_table;" + + qt_length2 """select k1,length(k2) from a_table order by k1;""" + qt_group2 """select k1,max_by_merge(k2) from a_table group by k1 order by k1;""" + qt_merge2 """select max_by_merge(k2) from a_table;""" + + qt_union """ select max_by_merge(kstate) from (select k1,max_by_union(k2) kstate from a_table group by k1 order by k1) t; """ + qt_max_by_null """ select max_by_merge(max_by_state(k1,null)),min_by_merge(min_by_state(null,k3)) from d_table; """ +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org