Skip to content

Incorrect result returned by a group by query (SQLancer-TLP) #11748

Closed

Description

@2010YOUY01

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

Activity

  1. Lordworms commented on Jul 31, 2024

    @Lordworms
    Contributor

    take

  2. HairstonE commented on May 10, 2026

    @HairstonE
    Contributor

    take

  3. added a commit that references this issue on Jul 27, 2026
    9ab2068
  4. added a commit that references this issue on Aug 12, 2026
    b7c63e2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions