Skip to content

sqlmesh format should not fully load the project when paths are given #6025

Description

@cmgoffena13

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions