[
https://issues.apache.org/jira/browse/CALCITE-5955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17768947#comment-17768947
]
Oliver Lee commented on CALCITE-5955:
-------------------------------------
One more thing to note... it appears ISO SQL and BigQuery allows for different
clauses following PERCENTILE_CONT:
BigQuery would allow something like
{quote}SELECT PERCENTILE_CONT(product_id, 0.5) OVER (PARTITION BY
product_class_id ORDER BY net_weight)
{quote}
whereas ISO SQL would expect
{quote}SELECT PERCENTILE_CONT( 0.5) WITHIN GROUP (ORDER BY net_weight) OVER
(PARTITION BY product_class_id)
{quote}
Note that in BQ, they are mixed in with 1 {{OVER}} clause, and ISO SQL has
WITHIN GROUP as well as OVER.
Currently the SQL statement in BQ does get parsed into
{{LogicalProject}}
{{-> exps = [RexOver]}}
-> {{rexOver.rexWindow has partitionKeys}} and {{orderKeys}}
This makes me think that we actually do want a {{RexOver}} node to represent
BigQuery. [~julianhyde] could you help provide some input?
If we want to keep it parsed as a RexOver node, then the changes I would make
would be to Parser.jj to do lookaheads and maybe individually detect for
percentile_cont with a big-query-style over clause
> BigQuery PERCENTILE functions are unparsed incorrectly
> ------------------------------------------------------
>
> 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
> Labels: pull-request-available
>
> 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)