Skip to content

feat: function to get range of key/value in model block#5119

Merged
benfdking merged 4 commits intomainfrom
refactor_code_to_be_shared
Aug 15, 2025
Merged

feat: function to get range of key/value in model block#5119
benfdking merged 4 commits intomainfrom
refactor_code_to_be_shared

Conversation

@benfdking
Copy link
Contributor

@benfdking benfdking commented Aug 11, 2025

Stages of the changes

  • refactor: refactor dialect parsing code to be reused
  • feat: add the ability to return range for key and value

Actual changes

  • improved the parsing logic and made it more robust
  • added the ability to return the value for the value range as well

@benfdking benfdking force-pushed the refactor_code_to_be_shared branch from 9728f66 to 6174549 Compare August 11, 2025 10:33
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 adds the ability to return ranges for both the key and its value when parsing MODEL block properties, improving upon the previous implementation that only returned the key range.

  • Refactored the dialect parsing code to be more robust and reusable
  • Enhanced the get_range_of_a_key_in_model_block function to return both key and value ranges as a tuple
  • Added comprehensive test coverage for various MODEL block property types and structures

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
sqlmesh/core/linter/helpers.py Complete rewrite of get_range_of_a_key_in_model_block to parse nested parentheses and return both key and value ranges
tests/core/linter/test_helpers.py Updated tests to handle the new tuple return format and added specific test cases for different value types

@benfdking benfdking force-pushed the refactor_code_to_be_shared branch from 6174549 to da3dad9 Compare August 14, 2025 10:17
@benfdking benfdking force-pushed the refactor_code_to_be_shared branch from 4822da8 to cc4a7fc Compare August 14, 2025 12:11
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Co-authored-by: Jo <46752250+georgesittas@users.noreply.github.com>
@benfdking benfdking enabled auto-merge (squash) August 15, 2025 09:21
@benfdking benfdking merged commit 943e496 into main Aug 15, 2025
26 of 28 checks passed
@benfdking benfdking deleted the refactor_code_to_be_shared branch August 15, 2025 09:34
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