Skip to content

Correlated EXISTS with constant-false predicate produces dangling mark column reference #22691

@xiedeyantu

Description

@xiedeyantu

Describe the bug

The following query fails during planning:

SELECT *
FROM t1
WHERE EXISTS (
    SELECT 1
    FROM t2
    WHERE t2.id = t1.id
      AND 1 = 0
)
OR t1.flag = TRUE;

with:

Schema error: No field named __correlated_sq_1.mark.
Valid fields are t1.id, t1.flag.

To Reproduce

CREATE TABLE t1 (
    id INT,
    flag BOOLEAN
);

CREATE TABLE t2 (
    id INT
);

SELECT *
FROM t1
WHERE EXISTS (
    SELECT 1
    FROM t2
    WHERE t2.id = t1.id
      AND 1 = 0
)
OR t1.flag = TRUE;

Expected behavior

The query should plan successfully.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions