-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(expr): support shuffle approx_percentile #17814
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
686983b
add state for single phase approx percentile + pass relative_error
kwannoel 2d189a1
estimate bucket id
kwannoel 08332bd
support in-memory approx percentile
kwannoel fd9a2a0
handle state encode / decode
kwannoel 1a31f3f
add tests and ensure single phase agg can work
kwannoel c3ad033
fix get_output
kwannoel 1cef150
recover test
kwannoel d242dab
fix state decoding and state type
kwannoel 72bbe3f
fix
kwannoel cb7ce18
add zero, neg buckets
kwannoel a74fa70
improve test, fix get_result
kwannoel 7101770
expose stack trace
kwannoel b74f2d6
fix
kwannoel 24845b9
fix
kwannoel 1e3bdc2
hide stack trace again
kwannoel 7ca78e5
address review
kwannoel a94a25a
Update e2e_test/streaming/aggregate/approx_percentile.slt
kwannoel b570a01
fix
kwannoel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,104 @@ | ||
# 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 | ||
approx_percentile(0.01, 0.01) within group (order by p_col) as p01, | ||
approx_percentile(0.1, 0.01) within group (order by p_col) as p10, | ||
approx_percentile(0.5, 0.01) within group (order by p_col) as p50, | ||
approx_percentile(0.9, 0.01) within group (order by p_col) as p90, | ||
approx_percentile(0.99, 0.01) within group (order by p_col) as p99 | ||
from t group by grp_col; | ||
---- | ||
-982.5779489474152 -804.4614206837127 0 804.4614206837127 982.5779489474152 | ||
|
||
query I | ||
select | ||
percentile_disc(0.01) within group (order by p_col) as p01, | ||
percentile_disc(0.1) within group (order by p_col) as p10, | ||
percentile_disc(0.5) within group (order by p_col) as p50, | ||
percentile_disc(0.9) within group (order by p_col) as p90, | ||
percentile_disc(0.99) within group (order by p_col) as p99 | ||
from t group by grp_col; | ||
---- | ||
-980 -800 0 800 980 | ||
|
||
statement ok | ||
create materialized view m1 as | ||
select | ||
approx_percentile(0.01, 0.01) within group (order by p_col) as p01, | ||
approx_percentile(0.1, 0.01) within group (order by p_col) as p10, | ||
approx_percentile(0.5, 0.01) within group (order by p_col) as p50, | ||
approx_percentile(0.9, 0.01) within group (order by p_col) as p90, | ||
approx_percentile(0.99, 0.01) within group (order by p_col) as p99 | ||
from t group by grp_col; | ||
|
||
query I | ||
select * from m1; | ||
---- | ||
-982.5779489474152 -804.4614206837127 0 804.4614206837127 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 -804.4614206837127 0 804.4614206837127 982.5779489474152 | ||
|
||
# Test state encode / decode | ||
onlyif can-use-recover | ||
statement ok | ||
recover; | ||
kwannoel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
onlyif can-use-recover | ||
sleep 10s | ||
|
||
query I | ||
select * from m1; | ||
---- | ||
-982.5779489474152 -804.4614206837127 0 804.4614206837127 982.5779489474152 | ||
|
||
# Test 0<x<1 values | ||
statement ok | ||
insert into t select 0.001, 1 from generate_series(1, 500); | ||
|
||
statement ok | ||
insert into t select 0.0001, 1 from generate_series(1, 501); | ||
|
||
statement ok | ||
flush; | ||
|
||
query I | ||
select * from m1; | ||
---- | ||
-963.1209598593477 -699.3618972397041 0.00009999833511933609 699.3618972397041 963.1209598593477 | ||
|
||
query I | ||
select | ||
percentile_disc(0.01) within group (order by p_col) as p01, | ||
percentile_disc(0.1) within group (order by p_col) as p10, | ||
percentile_disc(0.5) within group (order by p_col) as p50, | ||
percentile_disc(0.9) within group (order by p_col) as p90, | ||
percentile_disc(0.99) within group (order by p_col) as p99 | ||
from t group by grp_col; | ||
---- | ||
-970 -700 0.0001 700 970 | ||
|
||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In which cases we will set label
can-use-recover
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for e2e tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recover
should not be used in cases where tests can execute in parallel.