Fix!: Handle lookback correctly on incremental models with an end date defined #2962
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.
Slack context: https://tobiko-data.slack.com/archives/C044BRE5W4S/p1721917406454879
This PR allows
lookback
to return the correct missing intervals if the execution date is beyond the model's end date. Prior this,sqlmesh run
would always show a phantom interval for these models even if the current date was well beyond the model end date + lookback period.Assuming an incremental model with an end date of
2023-01-05
,@daily
intervals and a lookback of2
days:2023-01-05
so they don't want new intervals after 2023-01-052023-01-05
if they are within the lookback period2023-01-05
->2023-01-05
,2023-01-04
,2023-01-03
2023-01-06
->2023-01-04
,2023-01-05
2023-01-07
->2023-01-05
2023-01-08
-> (none, we are done)