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

Julian Hyde commented on CALCITE-7536:
--------------------------------------

Thanks; I agree with you on all points.

> Validator rejects legal queries with aggregates in WHERE clauses
> ----------------------------------------------------------------
>
>                 Key: CALCITE-7536
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7536
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.41.0
>            Reporter: Mihai Budiu
>            Priority: Minor
>
> The validator syntactically rejects queries that contain aggregates in WHERE, 
> even though such aggregates may depend on outer queries and could be 
> evaluated. For example, Postgres accepts the following query:
> {code}
> SELECT col1
> FROM (VALUES (1)) t1(col1)
> GROUP BY col1
>   HAVING (
>   SELECT MAX(t2.col1) != 0
>      FROM (VALUES (1)) t2(col1)
>      WHERE t2.col1 = t1.col1
>      GROUP BY t2.col1
>      HAVING (
>         SELECT t3.col1 != 0
>         FROM (VALUES (1)) t3(col1)
>         WHERE t3.col1 = MAX(t2.col1)
>      )
>   ) 
> {code}
> Calcite will reject it with:
> {code}
> Aggregate expression is illegal in WHERE clause 
> {code}



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

Reply via email to