Skip to content

Mark joins don't support null mark columns #21309

Closed

Description

@AdamGS

From the Story of Joins paper, for queries like:

select Title, ECTS = any (select ECTS from Courses c2
where Lecturer = 123) someE‘ual
from Courses c1

The result column someEqual can have the values TRUE, FALSE, and NULL (i.e.,
unknown). Accordingly, some care is needed to implement the mark join correctly, as we
will discuss in Section 5. But the great benefit is that we now translate arbitrary exists/not
exists/unique/quantified-comparison queries into a join construct and eventually, after
further optimizations, obtain an efficient evaluation strategy.

This seems like desirable behavior, and consistent with the general direction of subquery de-correlation.

This limitation also seems to be documented in null_aware_anti_join.slt, and currently returns wrong results:

# KNOWN LIMITATION: Mark joins used for OR conditions don't support null-aware semantics.
# The NULL row is incorrectly returned here. According to SQL semantics:
# - NULL NOT IN (2, 4) = UNKNOWN
# - NULL NOT IN (1, 3) = UNKNOWN
# - UNKNOWN OR UNKNOWN = UNKNOWN (should be filtered out)
# But mark joins treat NULL keys as non-matching (FALSE), so:
# - NULL mark column = FALSE
# - NOT FALSE OR NOT FALSE = TRUE OR TRUE = TRUE (incorrectly included)
# TODO: Implement null-aware support for mark joins to fix this

Activity

  1. AdamGS commented on Apr 1, 2026

    @AdamGS
    ContributorAuthor

    take

  2. neilconway commented on Apr 5, 2026

    @neilconway
    Contributor

    Cool! I'm also interested in this area.

  3. AdamGS commented on Apr 5, 2026

    @AdamGS
    ContributorAuthor

    I have a branch locally that somewhat works, it needs some more work and thinking

  4. AdamGS commented on Jun 16, 2026

    @AdamGS
    ContributorAuthor

    I've started splitting up my PR because its too big IMO and its a pain to handle, first part is #22981 which is mostly the SLT tests I had, documenting some of the current behavior.

  5. added a commit that references this issue on Sep 1, 2026
    bed9dcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions