Skip to main content

SQLFluff plugin for SQL and dbt model complexity rules

Project description

sqlfluff-complexity

SQLFluff rules and reports for finding SQL and dbt models that are too complex to review safely.

sqlfluff-complexity adds CPX rules to SQLFluff for CTE count, join count, nested subquery depth, CASE expressions, boolean predicates, window functions, and an aggregate weighted complexity score. The same metric engine also powers a companion sqlfluff-complexity report command for non-blocking console, JSON, and SARIF reports.

Who It Is For

  • Analytics engineers who want dbt models to stay small enough to review.
  • Data platform teams that already run SQLFluff in local development or CI.
  • Teams that want gradual complexity reporting before turning on strict lint failures.

Quick Start

Install the custom SQLFluff plugin in the same Python environment where you run SQLFluff:

pip install sqlfluff-complexity

If your project uses uv:

uv add --dev sqlfluff-complexity

Then enable CPX rules in .sqlfluff and run SQLFluff:

[sqlfluff]
dialect = postgres
rules = CPX_C101,CPX_C102,CPX_C103,CPX_C104,CPX_C105,CPX_C106,CPX_C201
sqlfluff lint models/

For a complete walkthrough, see docs/quickstart.md.

Documentation

  • Quick start: install, configure, and run the first lint.
  • Configuration: thresholds, aggregate weights, and path overrides.
  • Rules reference: CPX rule codes and what each metric counts.
  • Reporting: console and SARIF report mode.
  • dbt usage: SQLFluff dbt templater compatibility and v1 boundaries.
  • Dialects: tested dialects and dbt adapter mapping caveats.
  • Docs index: all user, contributor, and design documents.

Project Status

  • Native SQLFluff plugin rules and the companion report CLI are available in the package.
  • v1 measures SQLFluff-parsed SQL; direct dbt manifest.json and DAG-level metrics are deferred.
  • Architecture decisions are recorded in docs/adr/.

Development

Contributor setup, Nox sessions, fixture authoring, ADR workflow, and verifier guidance live in CONTRIBUTING.md. Agent-specific project instructions live in AGENTS.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sqlfluff_complexity-0.2.0.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sqlfluff_complexity-0.2.0-py3-none-any.whl (42.9 kB view details)

Uploaded Python 3

File details

Details for the file sqlfluff_complexity-0.2.0.tar.gz.

File metadata

  • Download URL: sqlfluff_complexity-0.2.0.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sqlfluff_complexity-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f84b2eaf947b83644ed5a2a396411fa08ed0b7c35050591da7bb6077e6f18d40
MD5 8df481925357c6d5ddcfd242c1ef0fb1
BLAKE2b-256 835a7bceeaf4cb024196a2ca9a6b7c1bdd7992c6ba4f8e149ef67e5c9694b9cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlfluff_complexity-0.2.0.tar.gz:

Publisher: publish.yml on yu-iskw/sqlfluff-complexity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sqlfluff_complexity-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlfluff_complexity-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb5e8d546c84566030f054b91849ba0706ac9bcb64e98a4034751697b9156e82
MD5 18523dd93db9c70a894f0f4bc86bdf8e
BLAKE2b-256 e68afda637aee36f1a5eb99af2aae127bcd3cbdd260e00911767c94158ebe1ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for sqlfluff_complexity-0.2.0-py3-none-any.whl:

Publisher: publish.yml on yu-iskw/sqlfluff-complexity

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page