Skip to content

feat: location in nomissingexternal models linting error#5049

Merged
benfdking merged 1 commit intomainfrom
working_on_external_model_placement
Jul 29, 2025
Merged

feat: location in nomissingexternal models linting error#5049
benfdking merged 1 commit intomainfrom
working_on_external_model_placement

Conversation

@benfdking
Copy link
Contributor

@benfdking benfdking commented Jul 28, 2025

Depends on

  • Adds the range to missing external models
  • Fixes a bug where non registered external models where not highlighting full thing for example in raw.demographics was only highlighting demographics

@benfdking benfdking force-pushed the working_on_external_model_placement branch 2 times, most recently from 096b683 to 2bca344 Compare July 28, 2025 21:37
@benfdking benfdking marked this pull request as ready for review July 28, 2025 21:38
@benfdking benfdking requested a review from Copilot July 28, 2025 21:38
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the location information for the nomissingexternalmodels linting rule by adding range information to violations and fixes a bug where unregistered external models with schema prefixes were not being highlighted correctly.

  • Creates a new sqlmesh/utils/lineage.py module with extracted reference-finding functionality
  • Updates the nomissingexternalmodels linter rule to provide precise location ranges for violations
  • Fixes highlighting to include full table names (e.g., raw.demographics instead of just demographics)

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sqlmesh/utils/lineage.py New module containing extracted reference-finding logic and LSP reference classes
sqlmesh/core/linter/rules/builtin.py Enhanced NoMissingExternalModels rule to provide location ranges for violations
sqlmesh/lsp/reference.py Refactored to use extracted functionality from new lineage module
sqlmesh/core/linter/helpers.py Added read_range_from_string helper function for reading text ranges
tests/lsp/test_reference_external_model.py Added test for unregistered external models with schema prefixes
tests/core/linter/test_builtin.py Updated test assertions for new violation format
sqlmesh/lsp/main.py Updated import for LSPExternalModelReference
sqlmesh/lsp/completions.py Updated import for generate_markdown_description
tests/utils/test_lineage_description.py Updated import path
vscode/extension/src/lsp/lsp.ts Fixed TypeScript type casting
sqlmesh/lsp/description.py Removed file (functionality moved to lineage module)
Comments suppressed due to low confidence (2)

sqlmesh/utils/lineage.py:88

  • The function read_range_from_string is duplicated between this file and sqlmesh/core/linter/helpers.py. Consider importing it from the helpers module instead of duplicating the implementation.
        root_scope = None

tests/lsp/test_reference_external_model.py:122

  • The test verifies that the range covers the full qualified name 'raw.demographics', but it doesn't test the specific bug mentioned in the PR description where only 'demographics' was highlighted. Consider adding an assertion that verifies the range start position to ensure the catalog/schema prefix is included.
    assert read_range_from_file(path, reference.range) == "raw.demographics"

@benfdking benfdking force-pushed the working_on_external_model_placement branch 3 times, most recently from 9d4e71e to eccbb8f Compare July 28, 2025 21:46
@benfdking benfdking force-pushed the working_on_external_model_placement branch 3 times, most recently from 43f02b1 to 6950c43 Compare July 29, 2025 10:34
@benfdking benfdking force-pushed the working_on_external_model_placement branch from 6950c43 to 908581b Compare July 29, 2025 10:44
@benfdking benfdking enabled auto-merge (squash) July 29, 2025 10:55
@benfdking benfdking merged commit 074df62 into main Jul 29, 2025
25 of 27 checks passed
@benfdking benfdking deleted the working_on_external_model_placement branch July 29, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants