Skip to content

Perf: add opt-in project-index loading for lint - #5913

Merged
yuki-kakegawa merged 6 commits into
SQLMesh:mainfrom
fresioAS:lint-scope-schema-resolution
Aug 25, 2026
Merged

yuki-kakegawa merged 6 commits into
SQLMesh:mainfrom
fresioAS:lint-scope-schema-resolution

Conversation

@fresioAS

@fresioAS fresioAS commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Description

Speeds up specific model linting. General use case would be for pre-commit - to not have to loop through the full project for specific models.

Add --use-project-index to targeted and full lint. The default path preserves the existing full context load. With both --use-project-index and --model, SQLMesh uses a persistent model-to-file dependency index to load, resolve, and validate only the selected models and their transitive upstream dependencies.

A full indexed lint still loads and lints every model, but creates or refreshes the index for later targeted commands. Missing or expanded dependencies safely retry with a full indexed load.

To mitigate long lint runs - #5907

Test Plan

Tested on live project (395 models)

=== Timing summary ===
sqlmesh lint --local 23.46s ok
sqlmesh lint --local --model sap.exposed.project 18.31s ok
sqlmesh lint --local --model sap.exposed.person 16.59s ok
sqlmesh lint --local --model sap.exposed.calendar 16.59s ok
sqlmesh lint --local --use-project-index 19.92s ok
sqlmesh lint --local --use-project-index --model sap.exposed.project 3.68s ok
sqlmesh lint --local --use-project-index --model sap.exposed.person 4.20s ok
sqlmesh lint --local --use-project-index --model sap.exposed.calendar 3.97s ok

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test)
  • My commits are signed off (git commit -s) per the DCO
@fresioAS
fresioAS marked this pull request as ready for review July 24, 2026 08:51
@fresioAS fresioAS mentioned this pull request Jul 24, 2026
4 tasks done
@fresioAS

Copy link
Copy Markdown
Contributor Author

@StuffbyYuki What is your take on this? The command is opt-in now, would it be better to default the functionality? or perhaps add it as a config setting?

Add --use-project-index to targeted and full lint. The default path preserves the existing full context load. With both --use-project-index and --model, SQLMesh uses a persistent model-to-file dependency index to load, resolve, and validate only the selected models and their transitive upstream dependencies.

A full indexed lint still loads and lints every model, but creates or refreshes the index for later targeted commands. Missing or expanded dependencies safely retry with a full indexed load.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Andreas Fredhøi <andreas.fredhoi@fresio.no>
@fresioAS
fresioAS force-pushed the lint-scope-schema-resolution branch from ec768aa to 44bb070 Compare July 24, 2026 12:24
Signed-off-by: Andreas Fredhøi <andreas.fredhoi@fresio.no>
@fresioAS
fresioAS force-pushed the lint-scope-schema-resolution branch from 44bb070 to bcbed2f Compare July 24, 2026 13:14
@yuki-kakegawa

Copy link
Copy Markdown
Collaborator

@fresioAS I’d keep the CLI opt-in for now. Turning this on by default changes lint --model semantics (unrelated model errors/validation are skipped), which is the right tradeoff for pre-commit but can be surprising as a silent default.

I think a config setting (e.g. under linter) would be a good next step though

@yuki-kakegawa yuki-kakegawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a blocker but these might be good follow up:

  1. Python API footgun: use_project_index=True is a no-op if the Context was already fully loaded (load=True). Perhaps document that on lint_models / load, or force a scoped reload when the flag is set.
  2. Config knob for the pre-commit UX (same as above)
fresioAS and others added 2 commits August 21, 2026 13:36
Signed-off-by: Andreas Fredhøi <andreas.fredhoi@fresio.no>
@yuki-kakegawa
yuki-kakegawa merged commit b44b9d3 into SQLMesh:main Aug 25, 2026
62 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants