Chore: Validate start and end dates during plan build time#5100
Merged
themisvaltinos merged 3 commits intomainfrom Aug 13, 2025
Merged
Chore: Validate start and end dates during plan build time#5100themisvaltinos merged 3 commits intomainfrom
themisvaltinos merged 3 commits intomainfrom
Conversation
erindru
approved these changes
Aug 6, 2025
6cb3b23 to
25c3acd
Compare
izeigerman
reviewed
Aug 7, 2025
sqlmesh/core/context.py
Outdated
| # Validate that the start is not greater than the end date / time | ||
| effective_start = start or default_start | ||
| effective_end = end or default_end | ||
| if effective_start is not None and effective_end is not None: |
Collaborator
There was a problem hiding this comment.
Let's have a separate function for this block
izeigerman
reviewed
Aug 7, 2025
sqlmesh/core/context.py
Outdated
| snapshot.node.start is None | ||
| or to_timestamp(snapshot.node.start) > end_ts | ||
| ): | ||
| raise SQLMeshError( |
Collaborator
There was a problem hiding this comment.
I don't think this is the right place to perform validation. With PlanBuilder users can set the start and end dynamically which means that currently they can pass this initial check and then set an invalid value later.
This should be moved into the PlanBuilder itself and the check needs to be performed every time build is called just like with other _ensure_* methods in the builder. Also, this should be PlanError.
Contributor
Author
There was a problem hiding this comment.
refactored and moved it to the _ensure_valid_date_range method which had similar logic and gets called in build
d93ca2b to
6e25a17
Compare
6e25a17 to
6485230
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.
Update to validate start is less than end date/time early during plan build time in the event that the user hasn't provided a start date in the config or in all models explicitly, fixes: #4916