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

Julian Hyde commented on CALCITE-5955:
--------------------------------------

As I've said before, {{PERCENTILE_CONT}} is an inverse distribution function, 
not a window function. BigQuery uses {{OVER}} syntax, but other databases (and 
ISO standard SQL) would write something like "SELECT PERCENTILE_CONT(0.5) 
WITHIN GROUP (ORDER BY x) ...". 

Let's not get confused by BigQuery's syntax. If Calcite has a RelNode tree that 
contains a call to PERCENTILE_CONT then of course we should generate BigQuery's 
native syntax, which uses OVER. But Calcite should not imagine that it is 
dealing with a window function (RexOver, Window).

When you say "you have a query like SELECT PERCENTILE_CONT(x, .5) OVER() ..." 
how does that query get into the system? Are you parsing that text? Or are you 
creating a RelNode tree similar to that query by making RelBuilder calls?

> Non-aggregate window functions incorrectly contain window frame clause for 
> BigQuery
> -----------------------------------------------------------------------------------
>
>                 Key: CALCITE-5955
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5955
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Tanner Clary
>            Assignee: Tanner Clary
>            Priority: Major
>
> Currently if you have a query like:
> {{SELECT PERCENTILE_CONT(x, .5) OVER() FROM x;}} the {{OVER()}} clause gets 
> unparsed with a {{window frame clause}} which BigQuery defines 
> [here|https://cloud.google.com/bigquery/docs/reference/standard-sql/window-function-calls#def_window_frame].
>  
> From the docs: "Only aggregate analytic functions can use a window frame 
> clause."
> This causes BigQuery to fail with the following error: {{Window framing 
> clause is not allowed for analytic function percentile_cont}}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to