Skip to content

fix(optimizer): preserve negated correlations [CODEX] - #7959

Closed
dev-willbird1936 wants to merge 1 commit into
tobymao:mainfrom
dev-willbird1936:fix/optimizer-negated-correlation
Closed

fix(optimizer): preserve negated correlations [CODEX]#7959
dev-willbird1936 wants to merge 1 commit into
tobymao:mainfrom
dev-willbird1936:fix/optimizer-negated-correlation

Conversation

@dev-willbird1936

Copy link
Copy Markdown
Contributor

Closes #7958.

A direct NOT around a correlated comparison was lost during decorrelation because the inner comparison was replaced with TRUE. This change normalizes supported direct negated comparisons to their complementary operator, aggregates the inner key when no positive equality join key exists, and evaluates the preserved predicate with ARRAY_ANY after a LEFT JOIN ... ON TRUE.

The regression covers EXISTS, NOT EXISTS, the existing positive-equality path, NULL/UNKNOWN values, an all-NULL inner relation, and an empty inner relation.

Validation:

  • focused optimizer and executor regressions
  • full executor suite: 22 passed
  • relevant unnest_subqueries optimizer fixture plus regression
  • Ruff check and format
  • mypy over 180 source files
  • git diff --check

LLM disclosure: I used OpenAI Codex to assist with analysis, implementation, and test drafting. I reviewed the final diff and validated the behavior and tests.

@geooo109 geooo109 assigned geooo109 and unassigned geooo109 Jul 27, 2026
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.

Correlated subquery unnesting collapses negated correlation predicates

3 participants