Summary
sqlmesh format already accepts positional paths and does not load state. With paths it still fully loads the project, then formats only the matching .sql models and audits. That load is wasted: format pretty-prints file text using dialect and format config. It does not need other models.
Current behavior
sqlmesh format models/orders.sql
Constructs Context with load=True, loads every model, then filters with Path.samefile.
Proposed behavior
sqlmesh format models/a.sql audits/unique_ids.sql
- Skip
Context.load() when positional paths are present
- Format only those files if they are SQL models or standalone audits
- Honor
formatting false
- Take dialect and
format: from the file’s project config and MODEL/AUDIT DDL
- Python model paths: ignore
macros/*.sql and other non-model SQL: no-op (same as today)
- No paths: still format all SQL models and audits (unchanged)
Acceptance
sqlmesh format models/a.sql does not parse unrelated models
- Formatted output for that file matches today’s formatter
sqlmesh format with no args is unchanged
- Unknown or non-model SQL paths are not rewritten
Summary
sqlmesh formatalready accepts positional paths and does not load state. With paths it still fully loads the project, then formats only the matching.sqlmodels and audits. That load is wasted: format pretty-prints file text using dialect and format config. It does not need other models.Current behavior
Constructs
Contextwithload=True, loads every model, then filters withPath.samefile.Proposed behavior
Context.load()when positional paths are presentformatting falseformat:from the file’s project config and MODEL/AUDIT DDLmacros/*.sqland other non-model SQL: no-op (same as today)Acceptance
sqlmesh format models/a.sqldoes not parse unrelated modelssqlmesh formatwith no args is unchanged