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

Merge a series of APPROX_PERCENTILE into a single ARRAY version #7

Open
kaikalur opened this issue Jan 7, 2021 · 0 comments
Open
Assignees

Comments

@kaikalur
Copy link

kaikalur commented Jan 7, 2021

Presto has two versions of APPROX_PERCENTILE - one that produces a single percentile and another that produces an array of APPROX_PERCENTILE values. So when you see something like:

SELECT
APPROX_PERCENTILE(x, 0.1) AS percentile_10,
APPROX_PERCENTILE(x, 0.2) AS percentile_20,
APPROX_PERCENTILE(x, 0.3) AS percentile_30
FROM T

Rewrite it it:

SELECT
percentiles[1] AS percentile_10,
percentiles[2] AS percentile_20,
percentiles[3] AS percentile_30
FROM (
SELECT APPROX_PERCENTILE(x, ARRAY[0.1, 0.2, 0.3]) AS percentiles
FROM T
)

@kaikalur kaikalur self-assigned this Jan 12, 2021
@kaikalur kaikalur assigned jnmugerwa and unassigned kaikalur and jnmugerwa Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants