Skip to content

Commit 4d1a3fc

Browse files
committed
Chore: Remove optional snapshot_is from get_snapshots() API
1 parent 00797d2 commit 4d1a3fc

4 files changed

Lines changed: 5 additions & 13 deletions

File tree

sqlmesh/core/state_sync/base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,12 @@ class StateReader(abc.ABC):
8686

8787
@abc.abstractmethod
8888
def get_snapshots(
89-
self,
90-
snapshot_ids: t.Optional[t.Iterable[SnapshotIdLike]],
89+
self, snapshot_ids: t.Iterable[SnapshotIdLike]
9190
) -> t.Dict[SnapshotId, Snapshot]:
9291
"""Bulk fetch snapshots given the corresponding snapshot ids.
9392
9493
Args:
95-
snapshot_ids: Iterable of snapshot ids to get. If not provided all
96-
available snapshots will be returned.
94+
snapshot_ids: Iterable of snapshot ids to get.
9795
9896
Returns:
9997
A dictionary of snapshot ids to snapshots for ones that could be found.

sqlmesh/core/state_sync/cache.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,8 @@ def _from_cache(
4646
return snapshot
4747

4848
def get_snapshots(
49-
self, snapshot_ids: t.Optional[t.Iterable[SnapshotIdLike]]
49+
self, snapshot_ids: t.Iterable[SnapshotIdLike]
5050
) -> t.Dict[SnapshotId, Snapshot]:
51-
if snapshot_ids is None:
52-
return self.state_sync.get_snapshots(snapshot_ids)
53-
5451
existing = {}
5552
missing = set()
5653
now = now_timestamp()

sqlmesh/core/state_sync/db/facade.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ def get_environments_summary(self) -> t.List[EnvironmentSummary]:
365365

366366
def get_snapshots(
367367
self,
368-
snapshot_ids: t.Optional[t.Iterable[SnapshotIdLike]],
368+
snapshot_ids: t.Iterable[SnapshotIdLike],
369369
) -> t.Dict[SnapshotId, Snapshot]:
370370
"""Fetches snapshots from the state.
371371

sqlmesh/core/state_sync/db/snapshot.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
)
3636
from sqlmesh.utils.migration import index_text_type, blob_text_type
3737
from sqlmesh.utils.date import now_timestamp, TimeLike, now, to_timestamp
38-
from sqlmesh.utils.errors import SQLMeshError
3938
from sqlmesh.utils.pydantic import PydanticModel
4039
from sqlmesh.utils import unique
4140

@@ -309,7 +308,7 @@ def touch_snapshots(self, snapshot_ids: t.Iterable[SnapshotIdLike]) -> None:
309308

310309
def get_snapshots(
311310
self,
312-
snapshot_ids: t.Optional[t.Iterable[SnapshotIdLike]],
311+
snapshot_ids: t.Iterable[SnapshotIdLike],
313312
) -> t.Dict[SnapshotId, Snapshot]:
314313
"""Fetches snapshots.
315314
@@ -319,8 +318,6 @@ def get_snapshots(
319318
Returns:
320319
A dictionary of snapshot IDs to snapshots.
321320
"""
322-
if snapshot_ids is None:
323-
raise SQLMeshError("Must provide snapshot IDs to fetch snapshots.")
324321
return self._get_snapshots(snapshot_ids)
325322

326323
def snapshots_exist(self, snapshot_ids: t.Iterable[SnapshotIdLike]) -> t.Set[SnapshotId]:

0 commit comments

Comments
 (0)