feat: location in nomissingexternal models linting error#5049
Merged
Conversation
096b683 to
2bca344
Compare
Contributor
There was a problem hiding this comment.
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.pymodule with extracted reference-finding functionality - Updates the
nomissingexternalmodelslinter rule to provide precise location ranges for violations - Fixes highlighting to include full table names (e.g.,
raw.demographicsinstead of justdemographics)
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_stringis duplicated between this file andsqlmesh/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"
9d4e71e to
eccbb8f
Compare
izeigerman
reviewed
Jul 28, 2025
izeigerman
reviewed
Jul 28, 2025
izeigerman
reviewed
Jul 28, 2025
izeigerman
approved these changes
Jul 28, 2025
43f02b1 to
6950c43
Compare
6950c43 to
908581b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on
raw.demographicswas only highlightingdemographics