[ 
https://issues.apache.org/jira/browse/CALCITE-4644?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17373752#comment-17373752
 ] 

Julian Hyde commented on CALCITE-4644:
--------------------------------------

I have done two things:
* The logic in {{SqlOperator.validatePercentileFunctionOperands}} looked very 
convoluted and very familiar. I noticed that it was doing the same thing as 
{{SqlValidatorUtil.flatten}}.  Which led me to the 
{{SqlValidatorImpl.validateAggregateParams}} method.
* I implemented my above suggestion " Maybe you could re-use the validation 
logic ... of RANGE."

and have pushed to my branch.

Two error messages need to be improved:
* "percentile_disc(0.25) within group (order by 'a')" gives error "Invalid 
type: 'CHAR'. Only NUMERIC types are supported". A better error would be 
"Invalid type 'CHAR' in ORDER BY clause of function 'PERCENTILE_DISC'. Only 
NUMERIC types are supported"
* "percentile_disc(0.25) within group (order by 1, 2)" gives error "Invalid 
number of arguments to function 'PERCENTILE_DISC'. Was expecting 1 arguments". 
A better error would be "Function 'PERCENTILE_DISC' requires precisely one 
ORDER BY key".

Can you improve them. Use my suggestions or whatever messages PostgreSQL gives 
for these situations. When you have done this, I am +1 for this PR.

> Add PERCENTILE_CONT and PERCENTILE_DISC aggregate functions
> -----------------------------------------------------------
>
>                 Key: CALCITE-4644
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4644
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Rafay A
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 4.5h
>  Remaining Estimate: 0h
>
> Add percentile functions in the operator table.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to