github-actions[bot] commented on code in PR #64778:
URL: https://github.com/apache/doris/pull/64778#discussion_r3466019278
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/rules/analysis/SubExprAnalyzer.java:
##########
@@ -97,6 +98,7 @@ public Expression visitExistsSubquery(Exists exists, T
context) {
throw new AnalysisException("Unsupported correlated subquery with
a LIMIT clause with offset > 0 "
+ analyzedResult.getLogicalPlan());
}
+ checkNoCorrelatedSlotsUnderSetOp(analyzedResult);
Review Comment:
This also rejects top-level scalar aggregate `EXISTS`/`NOT EXISTS` cases
before the existing constant-fold path can run. For example:
```text
Filter(EXISTS)
Aggregate(output=count(*), groupBy=[])
LogicalUnion
Filter(i.c1 = o.c1)
Filter(j.c1 = o.c1)
```
`checkNoCorrelatedSlotsUnderSetOp()` now walks into the `LogicalUnion` and
errors, but `SubqueryToApply` already treats `EXISTS` over a top-level scalar
aggregate as a constant: `subqueryToApply()` skips creating the apply, and
`ReplaceSubquery.visitExistsSubquery()` returns `TRUE` for `EXISTS` / `FALSE`
for `NOT EXISTS` because the aggregate without `GROUP BY` always returns one
row. So a previously supported query like `WHERE EXISTS (SELECT COUNT(*) FROM
(... UNION ALL ...) u)` now fails even though no set-operation decorrelation is
needed.
Please preserve that existing shortcut before applying the set-operation
rejection, either by folding this shape in `visitExistsSubquery` or by skipping
the new check when `hasTopLevelScalarAgg` would make `SubqueryToApply` replace
the subquery with a constant.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]