Skip to content

Commit f934466

Browse files
committed
add linting
1 parent d79f3b2 commit f934466

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

docs/examples/sqlmesh_cli_crash_course.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,65 @@ Pro tip: run this after running `sqlmesh table_diff` to get a full picture of th
615615
4 1 4 7
616616
```
617617

618+
### Linting
619+
620+
If enabled, this will run automatically during development. These can be overridden per model too.
621+
This is great to catch issues before wasting runtime in your data warehouse. You can run it manually to check for any issues.
622+
623+
=== "SQLMesh"
624+
625+
```bash
626+
sqlmesh lint
627+
```
628+
629+
=== "Tobiko Cloud"
630+
631+
```bash
632+
tcloud sqlmesh lint
633+
```
634+
635+
??? "Example Output"
636+
637+
You add linting rules in your `config.yaml` file.
638+
639+
```yaml
640+
gateways:
641+
duckdb:
642+
connection:
643+
type: duckdb
644+
database: db.db
645+
646+
default_gateway: duckdb
647+
648+
model_defaults:
649+
dialect: duckdb
650+
start: 2025-03-26
651+
652+
linter:
653+
enabled: true
654+
rules: ["ambiguousorinvalidcolumn", "invalidselectstarexpansion"] # raise errors for these rules
655+
warn_rules: ["noselectstar", "nomissingaudits"]
656+
# ignored_rules: ["noselectstar"]
657+
```
658+
659+
```bash
660+
[WARNING] Linter warnings for /Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/lint_warn.sql:
661+
- noselectstar: Query should not contain SELECT * on its outer most projections, even if it can be
662+
expanded.
663+
- nomissingaudits: Model `audits` must be configured to test data quality.
664+
[WARNING] Linter warnings for
665+
/Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/incremental_by_partition.sql:
666+
- nomissingaudits: Model `audits` must be configured to test data quality.
667+
[WARNING] Linter warnings for /Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/seed_model.sql:
668+
- nomissingaudits: Model `audits` must be configured to test data quality.
669+
[WARNING] Linter warnings for
670+
/Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/incremental_by_unique_key.sql:
671+
- nomissingaudits: Model `audits` must be configured to test data quality.
672+
[WARNING] Linter warnings for
673+
/Users/sung/Desktop/git_repos/sqlmesh-cli-revamp/models/incremental_model.sql:
674+
- nomissingaudits: Model `audits` must be configured to test data quality.
675+
```
676+
618677
## **Debugging Workflow**
619678

620679
You'll use these commands ad hoc to validate your changes are behaving as expected. Audits (data tests) are a great first step, and you'll want to evolve into to feel confident about the changes. The workflow is as follows:

0 commit comments

Comments
 (0)