Skip to main content

dataform-sqlx-lint

A convention linter for Dataform .sqlx files. SQL linters (sqlfluff) check the SQL body; dataform compile checks syntax. Neither sees the config-block and project conventions that keep a Dataform repo healthy — this tool does.

Zero dependencies (Python ≥ 3.11 standard library only). Designed for pre-commit.

pip install dataform-sqlx-lint

Rules

Code Default Checks
E001 on config {} block present and balanced
E002 on non-empty columns: {} documentation on tables/views/incrementals/declarations
E003 on schema: must not hardcode an environment suffix (_prod/_dev by default) — --schema-suffix appends it, so a literal doubles up (looker_prod_prod)
E004 on name: matching the filename is redundant (declarations exempt)
E005 opt-in operations/assertions must not set schema: (hasOutput: true operations exempt — schema+name define ${self()})
E006 on hardcoded `project.dataset.table` paths instead of ${ref()} — these silently break Dataform's dependency graph
E007 on* configurable per-directory naming/type policies (*no-op until policies are configured)
W008 opt-in post_operations {} placed before the main SELECT (style preference; Dataform accepts either)
E010 on every determinable output column appears in columns: {} — parses the main SELECT conservatively (unparseable expressions are skipped, never false-flagged) and follows select * through a single plain ${ref()} into the upstream file

Why E010 matters: columns: {} is what Dataform writes to BigQuery column descriptions — the metadata data catalogs, BI tools, and AI/conversational analytics agents read. Partial blocks leave silent gaps.

Usage

dataform-sqlx-lint definitions/output/my_table.sqlx [...]
# exit 0 = clean or warnings only; 1 = errors

Run from the repo root so --definitions-root (default ./definitions) can index ${ref()} targets for E010's star-resolution.

pre-commit

repos:
  - repo: https://github.com/acuantia/dataform-sqlx-lint
    rev: v0.1.0
    hooks:
      - id: dataform-sqlx-lint

Configuration

.sqlx-lint.toml in the repo root, or a [tool.sqlx-lint] table in pyproject.toml (the standalone file wins). All keys optional:

schema_suffixes = ["_prod", "_dev"]        # E003 suffix list ([] disables)
documented_types = ["table", "view", "incremental", "declaration"]  # E002
coverage_paths = ["definitions/output/"]   # E010 scope; empty = everywhere
enable = ["E005", "W008"]                  # switch on opt-in rules
disable = ["E004"]                         # switch off default rules

[[dir_policies]]                           # E007 (repeatable)
path_contains = "definitions/output/looker/"
require_prefix = "looker_"
require_types = ["table", "incremental"]
severity = "error"                         # or "warning"

See examples/acuantia.sqlx-lint.toml for a complete real-world config.

Suppressing findings

from `proj.raw_api.events` -- sqlx-lint: disable=E006 (declaration repoints at cutover)

or file-wide, anywhere in the file:

-- sqlx-lint: disable-file=E006

Suppress with a reason, sparingly — the convention is usually the fix.

Design notes

  • Conservative by construction: the SQL projection parser only claims column names it can determine (aliases, simple identifiers, resolvable select *); anything ambiguous is skipped, so E010 never false-flags.
  • Declarations are exempt from E003/E004 deliberately: raw source datasets legitimately carry environment-suffixed names, and Dataform requires name: on declarations.
  • Rule codes are stable; gaps in the numbering are historical.

Agent Skill

skills/dataform-sqlx-lint/ contains an Agent Skill — instructions that teach AI coding agents (Claude Code, Gemini CLI, Cursor, or any tool supporting the open skills format) to run this linter on every .sqlx file they create or modify. Install it by copying the folder into your agent's skills directory — or paste one of the ready-made prompts in skills/dataform-sqlx-lint/INSTALL_PROMPTS.md and let the agent install itself.

Development

python3 -m venv .venv && .venv/bin/pip install -e . pytest
.venv/bin/pytest        # 53 tests

License

MIT — see LICENSE.

Metadata

Release files for dataform-sqlx-lint 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dataform-sqlx-lint 0.1.2
File Size Uploaded
dataform_sqlx_lint-0.1.2.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dataform-sqlx-lint 0.1.2
File Interpreter ABI Platform
dataform_sqlx_lint-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 27.6 kB

Release files / dataform_sqlx_lint-0.1.2.tar.gz

Download URL dataform_sqlx_lint-0.1.2.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
09bd57b2e8a419f3969005aeadfd27382ed677675275eeed7b27189f2a5647ff
BLAKE2b-256 checksum
How to use checksums
70aab5173f21005b574267ded4e0895e7bb26c079796113070adbf2ab145a2b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release files / dataform_sqlx_lint-0.1.2-py3-none-any.whl

Download URL dataform_sqlx_lint-0.1.2-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0c9992c33616c4dd9ed9a2c2be2d39a10948efd492ad0218c8cb3c0bdb7462e7
BLAKE2b-256 checksum
How to use checksums
cae0215bc2976b49fe2dfa4d8659072867d7dd8483b5ef07ab1f3183ff7bf981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 2, 2026.

Transparency log

Release history Release notifications | RSS feed

0.2.0

2 release files

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page