Files
doris/regression-test/suites/function_p0/test_agg_foreach.groovy

96 lines
3.1 KiB
Groovy

// 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") {
// 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
// PERCENTILE PERCENTILE_ARRAY PERCENTILE_APPROX
// histogram
// GROUP_BIT_AND GROUP_BIT_OR GROUP_BIT_XOR
sql """ set enable_nereids_planner=true;"""
sql """ set enable_fallback_to_original_planner=false;"""
sql """
drop table if exists foreach_table;
"""
sql """
CREATE TABLE IF NOT EXISTS foreach_table (
`id` INT(11) null COMMENT "",
`a` array<INT> null COMMENT "",
`b` array<array<INT>> null COMMENT "",
`s` array<String> 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 values
(1,[1,2,3],[[1],[1,2,3],[2]],["ab","123"]),
(2,[20],[[2]],["cd"]),
(3,[100],[[1]],["efg"]) ,
(4,null,[null],null),
(5,[null,2],[[2],null],[null,'c']);
"""
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 ;
"""
qt_sql """
select sum_foreach(a) , stddev_foreach(a) ,stddev_samp_foreach(a) , variance_foreach(a) , var_samp_foreach(a) from foreach_table ;
"""
qt_sql """
select covar_foreach(a,a) , covar_samp_foreach(a,a) , corr_foreach(a,a) from foreach_table ;
"""
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 ;
"""
qt_sql """
select count_foreach(a) , count_by_enum_foreach(a) from foreach_table;
"""
qt_sql """
select PERCENTILE_foreach(a,a) from foreach_table;
"""
qt_sql """
select PERCENTILE_ARRAY_foreach(a,b) from foreach_table where id = 1;
"""
qt_sql """
select PERCENTILE_APPROX_foreach(a,a) from foreach_table;
"""
qt_sql """
select GROUP_BIT_AND_foreach(a), GROUP_BIT_OR_foreach(a), GROUP_BIT_XOR_foreach(a) from foreach_table;
"""
}