Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void register_aggregate_function_combinator_foreach(AggregateFunctionSimpleFacto
"name {} , args {}",
nested_function_name, types_name(types));
}
return creator_without_type::create<AggregateFunctionForEach>(transform_arguments, true,
nested_function);
return creator_without_type::create<AggregateFunctionForEach>(types, true, nested_function);
};
factory.register_foreach_function_combinator(
creator, AggregateFunctionForEach::AGG_FOREACH_SUFFIX, true);
Expand Down
49 changes: 49 additions & 0 deletions regression-test/data/function_p0/test_agg_foreach_notnull.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
[1, 2, 3] [1, 2, 3] [100, 2, 3] [100, 2, 3] [40.333333333333336, 2, 3] [85.95867768595042, 2, 3]

-- !sql --
[121, 4, 3] [42.89781139198388, 0, 0] [52.53887449625594, 0, null] [1840.222222222222, 0, 0] [2760.333333333333, 0, null]

-- !sql --
[1840.2222222222222, 0, 0] [2760.3333333333335, 0, null] [1, 0, 0]

-- !sql --
["{"20":1,"100":1,"1":1}", "{"2":2}", "{"3":1}"] ["{"20":1,"100":1,"1":1}", "{"2":2}", "{"3":1}"] [[100, 20, 1], [2], [3]] [[100, 20, 1], [2], [3]]

-- !sql --
[3, 2, 1] ["[{"cbe":{"100":1,"1":1,"20":1},"notnull":3,"null":1,"all":4}]", "[{"cbe":{"2":2},"notnull":2,"null":0,"all":2}]", "[{"cbe":{"3":1},"notnull":1,"null":0,"all":1}]"] [3, 1, 1]

-- !sql --
["{"num_buckets":3,"buckets":[{"lower":"1","upper":"1","ndv":1,"count":1,"pre_sum":0},{"lower":"20","upper":"20","ndv":1,"count":1,"pre_sum":1},{"lower":"100","upper":"100","ndv":1,"count":1,"pre_sum":2}]}", "{"num_buckets":1,"buckets":[{"lower":"2","upper":"2","ndv":1,"count":2,"pre_sum":0}]}", "{"num_buckets":1,"buckets":[{"lower":"3","upper":"3","ndv":1,"count":1,"pre_sum":0}]}"]

-- !sql --
[100, 2, 3]

-- !sql --
[[1], [2, 2, 2], [3]]

-- !sql --
[null, null, null]

-- !sql --
[0, 2, 3] [117, 2, 3] [113, 0, 3]

-- !sql --
["ab,cd,efg", "123,c", "114514"] ["ababcdabefg", "123123c", "114514"]

-- !sql --
[[1], [1], [1]] [[1, 1], [1, 1], [1, 1]] [[1, 1, 1], [1, 1, 1], [1, 1, 1]] [[1, 1, 1, 1], [1, 1, 1, 1], [1, 1, 1, 1]]

-- !sql --
["ab", "123", "114514"] [1, 2, 3]

-- !sql --
[[100, 20, 1], [2], [3]] [["efg", "cd", "ab"], ["c", "123"], ["114514"]] [[1], [2], [3]]

-- !sql --
[[1, 20, 100], [2, 2], [3]] [["ab", "cd", "efg"], ["123", "c"], ["114514"]] [[1], [2, 2], [3]]

-- !sql --
[{1:1, 20:20, 100:100}, {2:2}, {3:3}] [{1:"ab", 20:"cd", 100:"efg"}, {2:"123"}, {3:"114514"}] [{"ab":"ab", "cd":"cd", "efg":"efg"}, {"123":"123", "c":"c"}, {"114514":"114514"}]

129 changes: 129 additions & 0 deletions regression-test/suites/function_p0/test_agg_foreach_notnull.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// 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_foreach_not_null") {
// for nereids_planner
// now support min min_by maxmax_by avg avg_weighted sum stddev stddev_samp_foreach variance var_samp
// covar covar_samp corr
// topn topn_array topn_weighted
// count count_by_enum approx_count_distinct
// PERCENTILE PERCENTILE_ARRAY PERCENTILE_APPROX
// histogram
// GROUP_BIT_AND GROUP_BIT_OR GROUP_BIT_XOR
// any_value
// array_agg map_agg
// collect_set collect_list
// retention
// not support
// GROUP_BITMAP_XOR BITMAP_UNION HLL_UNION_AGG GROUPING GROUPING_ID BITMAP_AGG SEQUENCE-MATCH SEQUENCE-COUNT


sql """ set enable_nereids_planner=true;"""
sql """ set enable_fallback_to_original_planner=false;"""

sql """
drop table if exists foreach_table_not_null;
"""

sql """
CREATE TABLE IF NOT EXISTS foreach_table_not_null (
`id` INT(11) not null COMMENT "",
`a` array<INT> not null COMMENT "",
`b` array<array<INT>> not null COMMENT "",
`s` array<String> not null COMMENT ""
) ENGINE=OLAP
DUPLICATE KEY(`id`)
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"storage_format" = "V2"
);
"""
sql """
insert into foreach_table_not_null values
(1,[1,2,3],[[1],[1,2,3],[2]],["ab","123","114514"]),
(2,[20],[[2]],["cd"]),
(3,[100],[[1]],["efg"]) ,
(4,[null,2],[[2],null],[null,'c']);
"""

// this case also test combinator should be case-insensitive
qt_sql """
select min_ForEach(a), min_by_foreach(a,a),max_foreach(a),max_by_foreach(a,a) , avg_foreach(a),avg_weighted_foreach(a,a) from foreach_table_not_null ;
"""

qt_sql """
select sum_foreach(a) , stddev_foreach(a) ,stddev_samp_foreach(a) , variance_foreach(a) , var_samp_foreach(a) from foreach_table_not_null ;
"""

qt_sql """
select covar_foreach(a,a) , covar_samp_foreach(a,a) , corr_foreach(a,a) from foreach_table_not_null ;
"""
qt_sql """
select topn_foreach(a,a) ,topn_foreach(a,a,a) , topn_array_foreach(a,a) ,topn_array_foreach(a,a,a)from foreach_table_not_null ;
"""


qt_sql """
select count_foreach(a) , count_by_enum_foreach(a) , approx_count_distinct_foreach(a) from foreach_table_not_null;
"""

qt_sql """
select histogram_foreach(a) from foreach_table_not_null;
"""

qt_sql """
select PERCENTILE_foreach(a,a) from foreach_table_not_null;
"""

qt_sql """
select PERCENTILE_ARRAY_foreach(a,b) from foreach_table_not_null where id = 1;
"""

qt_sql """

select PERCENTILE_APPROX_foreach(a,a) from foreach_table_not_null;
"""

qt_sql """
select GROUP_BIT_AND_foreach(a), GROUP_BIT_OR_foreach(a), GROUP_BIT_XOR_foreach(a) from foreach_table_not_null;
"""

qt_sql """
select GROUP_CONCAT_foreach(s), GROUP_CONCAT_foreach(s,s) from foreach_table_not_null;
"""

qt_sql """
select retention_foreach(a), retention_foreach(a,a ),retention_foreach(a,a,a) , retention_foreach(a,a,a ,a) from foreach_table_not_null;
"""

qt_sql """
select any_value_foreach(s), any_value_foreach(a) from foreach_table_not_null;
"""

qt_sql """
select collect_set_foreach(a), collect_set_foreach(s) , collect_set_foreach(a,a) from foreach_table_not_null;
"""

qt_sql """
select collect_list_foreach(a), collect_list_foreach(s) , collect_list_foreach(a,a) from foreach_table_not_null;
"""

qt_sql """
select map_agg_foreach(a,a), map_agg_foreach(a,s) , map_agg_foreach(s,s) from foreach_table_not_null;
"""
}