Skip to content

Commit

Permalink
[regression](window_func) add test case for group_concat and hll_unio…
Browse files Browse the repository at this point in the history
…n_agg
  • Loading branch information
jacktengg committed Sep 11, 2024
1 parent 81bbd65 commit fd3139f
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,25 @@ USA Pete Hello
32767 6 12 32767
32767 6 6 32767

-- !window_func_hll_union_agg --
beijing linux 3
beijing macos 3
beijing windows 3
hebei windows 1
jiangsu macos 1
shanghai linux 2
shanghai windows 2
shanxi windows 1
shanxi windows 1

-- !window_func_hll_union_agg --
1 a
1 a,b
1 a,b,c
2 d
2 d,e
2 d,e,f
3 g
3 g,h
3 g,h,i

Original file line number Diff line number Diff line change
Expand Up @@ -498,5 +498,76 @@ suite("test_window_function") {
( SELECT k2, k1, row_number () over (PARTITION BY k2 ORDER BY k3) AS wj
FROM baseall ) AS A JOIN ( SELECT k2, k1, row_number () over
(PARTITION BY k2 ORDER BY k3) AS wj FROM baseall ) AS B WHERE A.k2=B.k2"""

// hll_union_agg
sql """drop TABLE if EXISTS test_window_func_hll;"""
sql """
create table test_window_func_hll(
dt date,
id int,
name char(10),
province char(10),
os char(10),
pv hll hll_union
)
Aggregate KEY (dt,id,name,province,os)
distributed by hash(id) buckets 10
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"storage_format" = "V2"
)
"""
sql """
insert into test_window_func_hll
SELECT
dt,id,name,province,os,pv
from (
SELECT '2022-05-05' as dt,'10001' as id,'test01' as name,'beijing' as province,'windows' as os,hll_hash('windows') as pv
union all
SELECT '2022-05-05' as dt,'10002' as id,'test01' as name,'beijing' as province,'linux' as os,hll_hash('linux') as pv
union all
SELECT '2022-05-05' as dt,'10003' as id,'test01' as name,'beijing' as province,'macos' as os,hll_hash('macos') as pv
union all
SELECT '2022-05-05' as dt,'10004' as id,'test01' as name,'hebei' as province,'windows' as os,hll_hash('windows') as pv
union all
SELECT '2022-05-06' as dt,'10001' as id,'test01' as name,'shanghai' as province,'windows' as os,hll_hash('windows') as pv
union all
SELECT '2022-05-06' as dt,'10002' as id,'test01' as name,'shanghai' as province,'linux' as os,hll_hash('linux') as pv
union all
SELECT '2022-05-06' as dt,'10003' as id,'test01' as name,'jiangsu' as province,'macos' as os,hll_hash('macos') as pv
union all
SELECT '2022-05-06' as dt,'10004' as id,'test01' as name,'shanxi' as province,'windows' as os,hll_hash('windows') as pv
union all
SELECT '2022-05-07' as dt,'10005' as id,'test01' as name,'shanxi' as province,'windows' as os,hll_empty() as pv
) as a
"""
order_qt_window_func_hll_union_agg"select province, os, hll_union_agg(hll_from_base64(hll_to_base64(pv))) over(partition by province) from test_window_func_hll;"

// group_concat
sql "DROP TABLE IF EXISTS test_window_func_group_concat;"
sql """
CREATE TABLE test_window_func_group_concat (
id int,
name varchar(10)
)
DISTRIBUTED BY HASH(id) BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);
"""
sql """
INSERT INTO test_window_func_group_concat VALUES
(1, 'a'),
(1, 'b'),
(1, 'c'),
(2, 'd'),
(2, 'e'),
(2, 'f'),
(3, 'g'),
(3, 'h'),
(3, 'i');
"""
order_qt_window_func_hll_union_agg "select id, group_concat(name) over(partition by id order by name) from test_window_func_group_concat;"

}

0 comments on commit fd3139f

Please sign in to comment.