Skip to content

Commit 648c5ce

Browse files
authored
fix: correctly skip loading archived snapshots (#2358)
1 parent a1c72e7 commit 648c5ce

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

sqlmesh/core/snapshot/definition.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,9 @@ def missing_intervals(
771771
Returns:
772772
A list of all the missing intervals as epoch timestamps.
773773
"""
774+
# If the node says that it has an end, and we are wanting to load past it, then we can return no empty intervals
775+
if self.node.end and to_datetime(start) > to_datetime(self.node.end):
776+
return []
774777
# If the amount of time being checked is less than the size of a single interval then we
775778
# know that there can't being missing intervals within that range and return
776779
validate_date_range(start, end)

tests/core/test_scheduler.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,12 @@ def test_intervals_with_end_date_on_model(mocker: MockerFixture, make_snapshot):
273273
assert len(batches) == 10
274274
assert batches[0] == (to_datetime("2023-01-01"), to_datetime("2023-01-02"))
275275
assert batches[-1] == (to_datetime("2023-01-10"), to_datetime("2023-01-11"))
276+
277+
# generate for the last day of range
278+
batches = scheduler.batches(start="2023-01-31", end="2023-01-31")[snapshot]
279+
assert len(batches) == 1
280+
assert batches[0] == (to_datetime("2023-01-31"), to_datetime("2023-02-01"))
281+
282+
# generate for future days to ensure no future batches are loaded
283+
snapshot_to_batches = scheduler.batches(start="2023-02-01", end="2023-02-28")
284+
assert len(snapshot_to_batches) == 0

0 commit comments

Comments
 (0)