Skip to content

sqlmesh lint should accept model file paths #6021

Description

@cmgoffena13

Summary

sqlmesh lint can target models with --model NAME, but not with file paths. Pre-commit and other path-based tools pass filenames, so lint cannot be wired up without a wrapper that maps paths to names.

Current behavior

  • sqlmesh lint --model sushi.orders works
  • sqlmesh lint models/orders.sql is a Click extra-arg error
  • sqlmesh lint --model models/orders.sql looks up a model with that name and fails
  • --local and --use-project-index already exist and should keep working when the selection comes from paths.

Proposed CLI

sqlmesh lint --local --use-project-index models/a.sql models/b.py

  • Add a positional paths argument (nargs=-1), same shape as sqlmesh format
  • Resolve each path to the model(s) whose _path matches
  • Keep --model for names; paths and --model can be combined
  • No paths and no --model still lints every model
  • With --use-project-index, path resolution should use the index (relative path -> FQNs) so unrelated models are not loaded

Acceptance

  • Lint of one changed model file does not lint the rest of the project
  • Python and SQL model files both work
  • Unknown path fails with a clear error (does not lint everything)
  • Existing --model usage is unchanged

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