Mihai Budiu created CALCITE-7536:
------------------------------------
Summary: 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
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)