Skip to content

fix(executor): preserve unmatched outer join rows [CODEX] - #7953

Merged
tobymao merged 1 commit into
tobymao:mainfrom
dev-willbird1936:fix/executor-outer-join-rows
Jul 27, 2026
Merged

fix(executor): preserve unmatched outer join rows [CODEX]#7953
tobymao merged 1 commit into
tobymao:mainfrom
dev-willbird1936:fix/executor-outer-join-rows

Conversation

@dev-willbird1936

Copy link
Copy Markdown
Contributor

Fixes #7952.

The Python executor previously filtered join candidates after constructing the join result. That loses preserved-side rows when a complete ON condition rejects a candidate, and it cannot synthesize both sides of a FULL JOIN.

This change evaluates the complete ON condition while constructing hash and nested-loop joins, tracks matched row indexes, and appends the required null-extended rows for LEFT, RIGHT, and FULL joins. One reusable condition context avoids per-pair setup cost.

Tests cover a disjoint FULL JOIN, a LEFT JOIN with a rejecting residual predicate, and nearby valid non-equi inner-join behavior.

Validation:

  • python -m unittest tests.test_executor.TestExecutor.test_outer_joins_preserve_unmatched_rows
  • python -m unittest tests.test_executor (22 passed)
  • pure-Python unit suite (1248 passed, 22 skipped)
  • Ruff lint and format checks
  • mypy (181 source files)

LLM disclosure: Codex assisted with validation, review, and preparation of this contribution. I reviewed the final behavior, tests, and diff and take responsibility for the submission.

@geooo109 geooo109 closed this Jul 27, 2026
@tobymao tobymao reopened this Jul 27, 2026
@tobymao
tobymao merged commit f85ea4c into tobymao:main Jul 27, 2026
16 checks passed
PiyaDaswadkar pushed a commit to PiyaDaswadkar/sqlglot that referenced this pull request Jul 29, 2026
Co-authored-by: dev-willbird1936 <dev-willbird1936@users.noreply.github.com>
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.

Python executor outer joins lose required null-extended rows

3 participants