Describe the bug
The below query should return an empty set, since having is evaluated after aggregation, when it's predicate is false, the final result should always be empty.
I have also checked in DuckDB and PostgreSQL, and they all return an empty set.
Reproducer in datafusion-cli
DataFusion CLI v40.0.0
> create table t1(v1 int);
0 row(s) fetched.
Elapsed 0.085 seconds.
> SELECT AVG(v1) FROM t1 GROUP BY false having false;
+------------+
| avg(t1.v1) |
+------------+
| |
+------------+
1 row(s) fetched.
Elapsed 0.095 seconds.
To Reproduce
No response
Expected behavior
No response
Additional context
Found by SQLancer #11030
Describe the bug
The below query should return an empty set, since
havingis evaluated after aggregation, when it's predicate is false, the final result should always be empty.I have also checked in DuckDB and PostgreSQL, and they all return an empty set.
Reproducer in datafusion-cli
To Reproduce
No response
Expected behavior
No response
Additional context
Found by SQLancer #11030