Skip to content

fix(lint): report a join condition that does not link the tables as GV003 (#156) - #164

Merged
laaielichter merged 1 commit into
laaielichter:mainfrom
Ipsita-Mondal-30:fix/lint-join-condition-links-tables
Nov 15, 2026
Merged

laaielichter merged 1 commit into
laaielichter:mainfrom
Ipsita-Mondal-30:fix/lint-join-condition-links-tables

Conversation

@Ipsita-Mondal-30

Copy link
Copy Markdown
Contributor

Closes #156

An ON condition counted as a key join whenever it contained any =, so ON 1=1 and ON t.id = t.id passed lint and the gate stayed open on a full cartesian product.

Change (src/gulliver/lint.py)
A new helper _on_link classifies the condition:

  • no column at all (ON 1=1, ON TRUE, ON 'a'='a'): GV003 error. ON TRUE was a GV008 warning before; it is the same cartesian product.
  • equalities that each stay inside one table (ON t.id = t.id, ON u.x = u.y): GV003 error, with a message saying the condition does not link the two tables.
  • an equality between columns of two different tables, with or without extra constant conditions: no finding, as before.
  • an unqualified column in an equality (ON id = user_id): no finding, because the side cannot be known.
  • USING, NATURAL, UNNEST/LATERAL and CROSS JOIN are untouched.

Not covered: a third table in a chain that is never linked (a JOIN b ON ... JOIN c ON a.id = b.id); the issue says this can be left out.

Tests (tests/test_lint.py): parametrized cases for each bullet above, plus the finding message. CHANGELOG line added. The README rule table is unchanged because the GV003 description did not change.

pytest (899 passed, 10 skipped) and ruff check . pass.

An ON condition now counts as a key join only when an equality compares
columns of two different tables. ON 1=1, ON TRUE and ON t.id = t.id are
reported as GV003 errors. A real key with extra conditions, unqualified
columns, USING, NATURAL and CROSS joins behave as before.

Closes laaielichter#156
@Ipsita-Mondal-30

Copy link
Copy Markdown
Contributor Author

Ran locally before opening: pytest (full suite) and ruff check . pass. The CI run is waiting for a maintainer to approve the workflow for a first-time contributor, so there is no CI result yet; could you approve it when you have a moment? Happy to adjust the approach or the wording of the messages.

@laaielichter laaielichter left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved on a055603. Thank you, @Ipsita-Mondal-30, this is a careful first PR. The _on_link helper is small and easy to read, and the "unqualified column means we cannot tell, so do not guess" rule is exactly the right call.

What I checked, on this head merged with current main (no conflicts with main):

  • ruff check . clean; full pytest 899 passed, 10 skipped.
  • Before (main): ON 1=1 and ON t.id = t.id give "No scale problems found", and gulliver run "select count(*) from events e join users u on 1=1" on the demo is OK. After: both are GV003 errors with a clear message, and the same run is now BLOCKED.
  • Also GV003 errors: ON TRUE, ON 'a' = 'a', ON x.id = x.id with aliases, and a later join in a chain (... join v on v.k = v.k).
  • No new findings: ON t.id = u.id AND 1=1, ON a.id = b.id, aliased x.id = y.id, ON id = user_id, USING, ON lower(t.n) = lower(u.n), an equality against a subquery, ON 1=1 inside a string or a comment, and ON t.id = u.id OR 1=1 (still the GV008 warning as before).
  • Mutation check: with src/gulliver/lint.py reverted to main, 7 of the new tests fail.
  • The diff is limited to lint.py, tests/test_lint.py and CHANGELOG.md.

Ready to merge from my side. It still needs the maintainer to approve the first-time CI runs (they show action_required for first-time contributors) and the 14 checks have to pass. I will add the "Thanks to @Ipsita-Mondal-30" credit to the CHANGELOG line, so you do not need to change it.

One heads-up, not a blocker: #165 also adds a line at the same spot in CHANGELOG.md, so whichever of the two lands second will need main merged and both lines kept.


Generated by Claude Code

@laaielichter
laaielichter merged commit b6ceba6 into laaielichter:main Nov 15, 2026
14 checks passed

Copy link
Copy Markdown
Owner

Merged, and welcome to Gulliver, @Ipsita-Mondal-30! Thank you for this first contribution. Telling apart a join condition that really links two tables from ON 1=1 or ON t.id = t.id closes a real hole where a full cartesian product slipped through the lint gate. The helper is clean, and listing what is deliberately not covered (the unlinked third table in a chain) made it easy to review.

If you want a next one: #159 (translate the README quick start into your language) is free and a good first issue. CONTRIBUTING.md has the setup and PR rules. Your #165 is next in the queue.

If Gulliver is useful to you, a ⭐ helps other people find it.


Generated by Claude Code

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.

Lint: JOIN u ON 1=1 and ON t.id = t.id get no finding, so a full cartesian product passes the gate and runs

2 participants