From 9498828548933244b1a155e93ffb9791a26c2674 Mon Sep 17 00:00:00 2001 From: Noel Kwan Date: Fri, 9 Aug 2024 00:25:26 +0800 Subject: [PATCH] fix row count + add test --- ...ase_approx_percentile_merge_normal_agg.slt | 93 +++++++++++++++++++ src/stream/src/executor/row_merge.rs | 16 +++- 2 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 e2e_test/streaming/aggregate/two_phase_approx_percentile_merge_normal_agg.slt diff --git a/e2e_test/streaming/aggregate/two_phase_approx_percentile_merge_normal_agg.slt b/e2e_test/streaming/aggregate/two_phase_approx_percentile_merge_normal_agg.slt new file mode 100644 index 0000000000000..299fa02e5bdfd --- /dev/null +++ b/e2e_test/streaming/aggregate/two_phase_approx_percentile_merge_normal_agg.slt @@ -0,0 +1,93 @@ +# Single phase approx percentile +statement ok +create table t(p_col double, grp_col int); + +statement ok +insert into t select a, 1 from generate_series(-1000, 1000) t(a); + +statement ok +flush; + +query I +select + percentile_cont(0.01) within group (order by p_col) as p01, + sum(p_col), + percentile_cont(0.5) within group (order by p_col) as p50, + count(*), + percentile_cont(0.99) within group (order by p_col) as p99 +from t; +---- +-980 0 0 2001 980 + +statement ok +create materialized view m1 as + select + approx_percentile(0.01, 0.01) within group (order by p_col) as p01, + sum(p_col), + approx_percentile(0.5, 0.01) within group (order by p_col) as p50, + count(*), + approx_percentile(0.99, 0.01) within group (order by p_col) as p99 + from t; + +query I +select * from m1; +---- +-982.5779489474152 0 0 2001 982.5779489474152 + +# Test state encode / decode +onlyif can-use-recover +statement ok +recover; + +onlyif can-use-recover +sleep 10s + +query I +select * from m1; +---- +-982.5779489474152 0 0 2001 982.5779489474152 + +# Test state encode / decode +onlyif can-use-recover +statement ok +recover; + +onlyif can-use-recover +sleep 10s + +query I +select * from m1; +---- +-982.5779489474152 0 0 2001 982.5779489474152 + +# Test 0