Repository navigation
Description
GV003 catches a join without a condition, and GV008 catches a join condition without an equality. A condition that contains an = but does not relate the two tables slips between the two rules: Gulliver sees an equality, concludes it is a key join, and reports nothing.
gulliver lint "select a from t join u on 1=1 limit 5"
# No scale problems found.
gulliver lint "select t.a from t join u on t.id = t.id limit 5"
# No scale problems found.
# for comparison, the same cartesian product written three other ways
gulliver lint "select a from t join u on true limit 5"
# warn GV008 non-equi-join: Join with u uses a non-equality or OR condition; ...
gulliver lint "select a from t, u where t.x > 3 limit 5"
# error GV003 cartesian-join: Join with u has no join condition: a cartesian product.
gulliver lint "select a from t cross join u limit 5"
# warn GV003 cartesian-join: CROSS JOIN with u multiplies row counts (rows A x rows B).Because nothing is reported, the gate stays open:
gulliver demo --events 20000
gulliver --dsn gulliver_demo.duckdb run "select count(*) from events e join users u on 1=1"
# **run** on `default` (duckdb) - **OK** <- 20,000 x 100,000 = 2 billion row pairs, no lint findingON 1=1 is a habit of query builders and of agents that "need a join condition"; ON t.id = t.id is the typo version (the same alias on both sides). Both are exactly what the tool is meant to stop.
Checked on current main (2bdae73). Why: in the GV003 / GV008 block of src/gulliver/lint.py the test is has_eq = any(True for _ in on.find_all(exp.EQ)); any EQ node counts, whatever its two sides are.
What should happen
An ON condition only counts as a key join when at least one equality compares a column of the joined table with a column of another table. Otherwise:
- no column at all in the condition (
ON 1=1,ON TRUE,ON 'a' = 'a'): GV003 error, the same finding as a join without a condition (todayON TRUEis a GV008 warning; it is the same cartesian product) - every equality has the same table on both sides (
ON t.id = t.id,ON u.x = u.y): GV003 error as well, with a message that says the condition does not link the two tables - a real key plus a constant (
ON t.id = u.id AND 1=1,ON t.id = u.id AND u.kind = 'x'): no finding, as today - columns without a table qualifier (
ON id = user_id): no finding; Gulliver cannot know which side they come from, so it must not guess USING (...),NATURAL JOIN,UNNEST/LATERALjoins andCROSS JOINbehave as today
Where to start
src/gulliver/lint.py: the GV003 / GV008 block insidelint(...)(around lines 247-287)._join_condition(...)(line 93) and_aliases_in(...)(line 97) are the helpers; for eachexp.EQin theON, collect thetableof theexp.Columnnodes on the left and on the right and compare them with the joined table's alias (aliasin that loop)- A join like
a JOIN b ON ... JOIN c ON a.id = b.id(the third table is never linked) is the same problem one level up; it is fine to leave it out, say so in the PR - Tests:
tests/test_lint.py, next totest_non_equi_join(line 89). The repo's own SQL intests/and the README examples must stay free of new findings README.md"Scale lint rules" is generated fromgulliver rules --format markdown; update the GV003 description inlint.pyif the wording changes and regenerate the table
How to test
gulliver lint "select a from t join u on 1=1 limit 5" # now: error GV003
gulliver lint "select t.a from t join u on t.id = t.id limit 5" # now: error GV003
gulliver lint "select t.a from t join u on t.id = u.id and 1=1 limit 5" # still: No scale problems found.
pytest tests/test_lint.pyDone when
-
ON 1=1,ON TRUEandON t.id = t.idare reported as GV003 errors and blockpreflight/run - A key equality between the two tables, with or without extra constant conditions, gives no finding
- Unqualified columns and
USINGgive no new finding - Tests for each case above
- A line under
UnreleasedinCHANGELOG.md -
pytestandruff check .pass
Please comment with your plan before writing a lot of code, as CONTRIBUTING.md asks for bigger changes.
Comment here to claim it and you'll be assigned.
Activity
Ipsita-Mondal-30 commentedon Nov 14, 2026
Hi, I'd like to work on this. I'll open a PR with tests shortly.
laaielichter commentedon Nov 14, 2026
Welcome to Gulliver, @Ipsita-Mondal-30, and thanks for picking this up! I've assigned you #156 (and #157, where you also commented). I see you already opened PRs #164 and #165, so I'll review them. If you haven't yet, CONTRIBUTING.md lists the checks to run before review (
pytest,ruff check .) and the CHANGELOG line underUnreleased.If Gulliver is useful to you, a ⭐ helps other people find it.
Generated by Claude Code
Merge pull request #164 from Ipsita-Mondal-30/fix/lint-join-condition…
lint: report a join condition that does not link the tables as GV003
lint: report a join condition that does not link the tables as GV003
lint: report a join condition that does not link the tables as GV003