Skip to content

Commit c7e3fa5

Browse files
committed
Implement ModelKindMixin on SnapshotIdAndVersion
1 parent 924e59e commit c7e3fa5

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

sqlmesh/core/plan/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def identify_restatement_intervals_across_snapshot_versions(
181181
# So for now, these are not considered
182182
s_id
183183
for s_id, s in snapshot_intervals_to_clear.items()
184-
if s.snapshot.kind_name and s.snapshot.kind_name.full_history_restatement_only
184+
if s.snapshot.full_history_restatement_only
185185
]
186186
if full_history_restatement_snapshot_ids:
187187
# only load full snapshot records that we havent already loaded

sqlmesh/core/snapshot/definition.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,14 +599,14 @@ def id_and_version(self) -> SnapshotIdAndVersion:
599599
)
600600

601601

602-
class SnapshotIdAndVersion(PydanticModel):
602+
class SnapshotIdAndVersion(PydanticModel, ModelKindMixin):
603603
"""A stripped down version of a snapshot that is used in situations where we want to fetch the main fields of the snapshots table
604604
without the overhead of parsing the full snapshot payload and fetching intervals.
605605
"""
606606

607607
name: str
608608
version: str
609-
kind_name: t.Optional[ModelKindName] = None
609+
kind_name_: t.Optional[ModelKindName] = Field(default=None, alias="kind_name")
610610
dev_version_: t.Optional[str] = Field(alias="dev_version")
611611
identifier: str
612612
fingerprint_: t.Union[str, SnapshotFingerprint] = Field(alias="fingerprint")
@@ -634,6 +634,10 @@ def fingerprint(self) -> SnapshotFingerprint:
634634
def dev_version(self) -> str:
635635
return self.dev_version_ or self.fingerprint.to_version()
636636

637+
@property
638+
def model_kind_name(self) -> t.Optional[ModelKindName]:
639+
return self.kind_name_
640+
637641

638642
class Snapshot(PydanticModel, SnapshotInfoMixin):
639643
"""A snapshot represents a node at a certain point in time.

tests/core/test_snapshot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3578,7 +3578,7 @@ def test_snapshot_id_and_version_optional_kind_name():
35783578
fingerprint="",
35793579
)
35803580

3581-
assert snapshot.kind_name is None
3581+
assert snapshot.model_kind_name is None
35823582

35833583
snapshot = SnapshotIdAndVersion(
35843584
name="a",
@@ -3589,6 +3589,6 @@ def test_snapshot_id_and_version_optional_kind_name():
35893589
fingerprint="",
35903590
)
35913591

3592-
assert snapshot.kind_name
3593-
assert snapshot.kind_name.is_incremental_unmanaged
3594-
assert snapshot.kind_name.full_history_restatement_only
3592+
assert snapshot.model_kind_name
3593+
assert snapshot.is_incremental_unmanaged
3594+
assert snapshot.full_history_restatement_only

0 commit comments

Comments
 (0)