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.

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.0

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.0
File Size Uploaded
dataform_sqlx_lint-0.1.0.tar.gz 15.1 kB Details

Built distribution (wheel)

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

Total release size: 26.9 kB

Release files / dataform_sqlx_lint-0.1.0.tar.gz

Download URL dataform_sqlx_lint-0.1.0.tar.gz
Size 15.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4e03898f68cc43985cf5e21e78b67e646840e48a06f6ef3253c1ec247772284c
BLAKE2b-256 checksum
How to use checksums
aa7987e27c28d3adf120e95734fa0ee90682120302d3ed97f0f13fc9217b7f2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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

Download URL dataform_sqlx_lint-0.1.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ff11f6f24f36c226d32e8613a815e28ec8460e93dec0d12e8314f2cd83ac4be
BLAKE2b-256 checksum
How to use checksums
1a5ae45b4fe5aab9ced12948725e00893e4dda2c93bed211c001f6bfba837671
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

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