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

quantile_cont/disc ORDER BY support #11419

Closed
1 task done
soerenwolfers opened this issue Mar 29, 2024 · 3 comments · Fixed by #11428
Closed
1 task done

quantile_cont/disc ORDER BY support #11419

soerenwolfers opened this issue Mar 29, 2024 · 3 comments · Fixed by #11428

Comments

@soerenwolfers
Copy link
Contributor

soerenwolfers commented Mar 29, 2024

What happens?

quantile_cont and quantile_disc doesn't currently support ordering, so that the ugly SQL standard WITHIN GROUP aggregates are required when quantile_cont(column, q ORDER BY column DESC) is desired.

Additionally, it is not currently possible even with the WITHIN GROUP aggregates, to achieve quantile_disc(column, q ORDER BY other_column) (which seems nonsensical at first, but is perfectly well-defined and useful, I promise.)

To Reproduce

SELECT 
    percentile_cont(0.8) WITHIN GROUP (ORDER BY x DESC),
    quantile_cont(x, 0.8 ORDER BY x DESC),
FROM 
    (VALUES (2), (1)) _(x);
BinderException: Binder Error: No function matches the given name and argument types 'quantile_cont(INTEGER, INTEGER, DECIMAL(2,1))'. You might need to add explicit type casts.

OS:

Linux

DuckDB Version:

0.10.2

DuckDB Client:

Python

Full Name:

Soeren Wolfers

Affiliation:

G-Research

Have you tried this on the latest nightly build?

I have tested with a nightly build

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • Yes, I have
@hawkfish
Copy link
Contributor

Sorry, battling features. We should not be injecting the missing arguments when they are not missing...

Incidentally I hope to get to windowed versions with independent sorting axes after 1.0.

hawkfish added a commit to hawkfish/duckdb that referenced this issue Mar 29, 2024
The PERCENTILE_XXX rewrite was colliding with the sorted aggregate rewrite here.
Also cleaned up the quantile negation logic to not have scary holes...

fixes: duckdb#11419
fixes: duckdblabs/duckdb-internal#1712
@soerenwolfers
Copy link
Contributor Author

Great to hear that's on your radar. Am I justified to be optimistic that this will bring a positive resolution to #11425 eventually as well?

@soerenwolfers
Copy link
Contributor Author

Also, sorry to hijack this even more, but since you seem to be the window expert: do you think there is any hope for #10703?

Mytherin added a commit that referenced this issue Mar 30, 2024
ccfelius pushed a commit to ccfelius/duckdb that referenced this issue Apr 6, 2024
The PERCENTILE_XXX rewrite was colliding with the sorted aggregate rewrite here.
Also cleaned up the quantile negation logic to not have scary holes...

fixes: duckdb#11419
fixes: duckdblabs/duckdb-internal#1712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants