Skip to content

rule: W022 cross-join-explicit - warn on explicit CROSS JOIN #8

@Pawansingh3889

Description

@Pawansingh3889

S001 implicit-cross-join catches FROM a, b. But explicit CROSS JOIN
slips through. Cross joins are rarely intentional outside of lookup-table
generation (calendars, cohort grids). Warn so the author confirms intent.

Should fail

SELECT *
FROM products p
CROSS JOIN regions r;

Should pass

SELECT *
FROM calendar_dates
CROSS JOIN (SELECT 1 AS n UNION ALL SELECT 2);
-- with an explicit "-- noqa: W018" comment to allow

Implementation hints

  • Single-line rule.
  • Regex: r"\bCROSS\s+JOIN\b".
  • Severity: warning.
  • Bonus: support -- noqa: W018 comment to suppress.

Estimated LOC: ~20 code + ~15 test + (optional) noqa plumbing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions