8000 fix(or): join an or sharing no variable with earlier clauses as a cross product (#610) by adityamukho · Pull Request #612 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

fix(or): join an or sharing no variable with earlier clauses as a cross product (#610) - #612

Merged
adityamukho merged 2 commits into
v3from
fix/610-or-cross-product
Oct 16, 2026
Merged

adityamukho merged 2 commits into
v3from
fix/610-or-cross-product

Conversation

@adityamukho
@adityamukho adityamukho commented Oct 16, 2026 •
Copy link
Copy Markdown
Collaborator

For #610.

Problem

[?x :edge ?z] (or [?p :edge :b] [?p :edge :c]) returned no rows. In apply_or_clauses, the fast path (no not/not-join/pseudo-attribute in any branch) replaced the incoming rows with the branch union when they shared no user-visible variable. It assumed the incoming rows were the empty start row. After an earlier clause binding other variables, ?x was lost and projection dropped every row. The seeded path (a branch with not) was already correct.

Fix

The special case is removed. With no shared variable the general hash join's key is empty, so each incoming row joins every branch row, giving the cross product. When the incoming row is the empty start row, the result is the same as before. The fix covers queries and rule bodies, since both go through apply_or_clauses.

or-join keeps refusing a join variable that no earlier clause binds (INT-018). In Minigraf or-join filters on variables already bound and does not add new ones, so the refusal matches its semantics. or binds its branch variables, so it must evaluate this shape.

Tests

Six new tests in tests/disjunction_test.rs cover:

  • the cross product with the or placed after the other clauses and before them
  • the earlier clauses' variables kept in the result
  • no rows when no branch matches
  • the seeded path
  • an or in a rule body
  • incoming rows that carry fact metadata from a pseudo-attribute (gap found in the Codex review)

Four of them failed before the fix. Full suite: 1,544 passing, 10 ignored. cargo clippy --all-features -D warnings is clean.

Backport to main (v2.0.x) to follow, under the "all bug fixes until v3.0.0" policy.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HyLscCUuJ1GQpdAeX79EdR

adityamukho and others added 2 commits October 16, 2026 12:54
…ss product (#610)

apply_or_clauses' fast path replaced the incoming rows with the branch union
when the two shared no user-visible variable, assuming the incoming rows were
the empty start row. After any earlier clause that binds other variables, the
rows lost those variables and projection dropped them, so the query returned
nothing. The general hash join already handles this: with no shared variable
every key is empty and each incoming row joins every branch row. The special
case is removed. or-join keeps refusing unbound join variables (INT-018); it
filters, it does not bind.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HyLscCUuJ1GQpdAeX79EdR
@codecov
codecov Bot commented Oct 16, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit 8e1f771 into v3 Oct 16, 2026
25 checks passed
@adityamukho
adityamukho deleted the fix/610-or-cross-product branch October 16, 2026 07:48
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.

1 participant

0