Skip to content

Conversation

Tmonster
Copy link
Contributor

@Tmonster Tmonster commented Feb 9, 2023

A Group by all with a Having clause has special behavior during binding, which makes it difficult to handle correlated subqueries. This error should fix fuzzer issues 8, 12, and 15.
In fuzzer issue 8, the column c1 in the select clause references a column from a subquery in the from clause. c1 is also grouped on using the group by all, and is then in the having clause. The group by all forces aggregates, which requires special handling during binding. Since the column is also in a correlated subquery, the handling should be extended to also extract the column binding from the correlated subquery, but that will be a lot of work that hopefully someone can pay us for in the future. The current solution is just to throw a binder error.

Issue 8
SELECT 1 alias1 FROM (SELECT 1) t2(c1) GROUP BY ALL HAVING (SELECT c1);

Issue 12
SELECT 1 FROM (SELECT 1) t1(c0) GROUP BY ALL HAVING EXISTS (SELECT 1 FROM (SELECT 1) t0(c2) HAVING c0); issue 12

Issue 15
SELECT 0 c0 FROM t1 GROUP BY ALL HAVING c0 < ALL(SELECT 0 FROM ((SELECT 2) UNION (SELECT 2)) t2 WHERE substr('b', 1, c0) GROUP BY ALL);

@Mytherin Mytherin merged commit c60ef24 into duckdb:master Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants