Skip to content
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

Support percentile_cont via approx_percentile #18008

Closed
kwannoel opened this issue Aug 12, 2024 · 3 comments
Closed

Support percentile_cont via approx_percentile #18008

kwannoel opened this issue Aug 12, 2024 · 3 comments
Labels
good first issue Good for newcomers help wanted Issues that need help from contributors type/feature

Comments

@kwannoel
Copy link
Contributor

kwannoel commented Aug 12, 2024

Now that we support approx percentile, perhaps we can support streaming percentile_cont via approx_percentile too, by simply setting relative_error to 0.

Most of the work just needs to take place in the frontend.

@kwannoel kwannoel changed the title Support percentile_cont via approx_percentile Support percentile_cont via approx_percentile Aug 12, 2024
@github-actions github-actions bot added this to the release-2.0 milestone Aug 12, 2024
@kwannoel kwannoel modified the milestones: release-2.0, release-2.1 Aug 19, 2024
@kwannoel kwannoel added the good first issue Good for newcomers label Aug 20, 2024
@kwannoel kwannoel removed this from the release-2.1 milestone Aug 20, 2024
@kwannoel kwannoel added help wanted Issues that need help from contributors and removed needs-discussion labels Aug 20, 2024
@chagelo
Copy link

chagelo commented Sep 16, 2024

SELECT percentile_cont(x) WITHIN GROUP (ORDER BY column1) FROM table1; gets nonzero, while SELECT approx_percentile(x, 0) WITHIN GROUP (ORDER BY column1) FROM table1; always gets zero, but I'm not familar with "streaming" and hdr, and I'm not sure whether it's correct that approx_percentile return zero.

@kwannoel
Copy link
Contributor Author

SELECT percentile_cont(x) WITHIN GROUP (ORDER BY column1) FROM table1; gets nonzero, while SELECT approx_percentile(x, 0) WITHIN GROUP (ORDER BY column1) FROM table1; always gets zero, but I'm not familar with "streaming" and hdr, and I'm not sure whether it's correct that approx_percentile return zero.

It's a bug. Thanks for catching it. Will submit a PR to fix it shortly.

@kwannoel
Copy link
Contributor Author

kwannoel commented Sep 16, 2024

Actually it is tricky to support it via approx_percentile. That's because we will have to override the semantics of bucket_id to handle relative_error = 0.0. In order to keep the precision of original value when relative_error = 0.0, we have to store bucket_id (this is also the original value when relative_error = 0.0) as a f32/f64 instead of i32. That means the range of values we can do approx_percentile for will be less.

To avoid this extra complexity and trade-off, we should implement percentile_cont first, and map approx_percentile(x, 0.0) to it instead. So it's the other way around.

Tracking issue to support percentile_cont: #12857.

Closing this issue.

@kwannoel kwannoel closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Issues that need help from contributors type/feature
Projects
None yet
Development

No branches or pull requests

2 participants