[
https://issues.apache.org/jira/browse/CALCITE-5955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17768946#comment-17768946
]
Oliver Lee commented on CALCITE-5955:
-------------------------------------
Putting breakpoints in the test Tanner has set up, I see that the {{RelNode}}
for the current BigQuery {{PERCENTILE_CONT2 at this
[point|https://github.com/apache/calcite/blob/cc73aba9b4af0c3af5ac96422518a821e951cb9b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java#L7646]
is a LogicalProject}} with a {{RexOver that has {{op}} of
{{{}SqlBasicAggFunction.PERCENTILE_CONT{}}}2}}
When I send in SQL for non-BQ syntax/library, the {{RelNode}} is a
{{LogicalAggregate}} with {{aggFunction}}
{{SqlBasicAggFunction.PERCENTILE_CONT}}
I think the desired behavior [~julianhyde] is describing is that we want the
new PERCENTILE_CONT2 to be parsed such that it is a {{LogicalAggregate}} and
not a {{RexOver}}
To me this sounds like we would need parser level changes to handle this since
the
[current|https://github.com/apache/calcite/blob/cc73aba9b4af0c3af5ac96422518a821e951cb9b/core/src/main/codegen/templates/Parser.jj#L4068]
PercentileFunctionCall() parsing notes that WITHIN GROUP and OVER is handled
outside of that
> 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)