-
Notifications
You must be signed in to change notification settings - Fork 589
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stream): add two-phase stateless simple approx percentile (#17873)
- Loading branch information
Showing
16 changed files
with
660 additions
and
9 deletions.
There are no files selected for viewing
File renamed without changes.
78 changes: 78 additions & 0 deletions
78
e2e_test/streaming/aggregate/two_phase_approx_percentile.slt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# 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(0, 10) t(a); | ||
|
||
statement ok | ||
insert into t values(0, 1); | ||
|
||
statement ok | ||
flush; | ||
|
||
statement ok | ||
create materialized view m1 as select | ||
approx_percentile(0.01, 0.01) within group (order by p_col) as p01 | ||
from t; | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from m1; | ||
---- | ||
0 | ||
|
||
query I | ||
select percentile_cont(0.01) within group (order by p_col) from t; | ||
---- | ||
0 | ||
|
||
statement ok | ||
insert into t select a, 1 from generate_series(11, 1000) t(a); | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from m1; | ||
---- | ||
8.93541864376352 | ||
|
||
query I | ||
select percentile_cont(0.01) within group (order by p_col) from t; | ||
---- | ||
9.01 | ||
|
||
query I | ||
select approx_percentile(0.01, 0.01) within group (order by p_col) from t group by grp_col; | ||
---- | ||
8.93541864376352 | ||
|
||
statement ok | ||
insert into t select a, 1 from generate_series(-1000, -1) t(a); | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from m1; | ||
---- | ||
-982.5779489474152 | ||
|
||
query I | ||
select approx_percentile(0.01, 0.01) within group (order by p_col) from t group by grp_col; | ||
---- | ||
-982.5779489474152 | ||
|
||
query I | ||
select percentile_cont(0.01) within group (order by p_col) from t; | ||
---- | ||
-979.99 | ||
|
||
statement ok | ||
drop materialized view m1; | ||
|
||
statement ok | ||
drop table t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.