Skip to content

Commit 7f650e1

Browse files
authored
Fix: Always create views in the virtual layer for expired environments (#3575)
1 parent dc7b0b0 commit 7f650e1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

sqlmesh/core/state_sync/engine_adapter.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,11 @@ def promote(
325325
}
326326

327327
added_table_infos = set(table_infos.values())
328-
if existing_environment and existing_environment.finalized_ts:
328+
if (
329+
existing_environment
330+
and existing_environment.finalized_ts
331+
and not existing_environment.expiration_ts
332+
):
329333
# Only promote new snapshots.
330334
added_table_infos -= set(existing_environment.promoted_snapshots)
331335

tests/core/test_state_sync.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ def test_promote_environment_expired(state_sync: EngineAdapterStateSync, make_sn
870870

871871
state_sync.push_snapshots([snapshot])
872872
promote_snapshots(state_sync, [snapshot], "dev")
873+
state_sync.finalize(state_sync.get_environment("dev"))
873874
state_sync.invalidate_environment("dev")
874875

875876
new_environment = Environment(
@@ -882,7 +883,10 @@ def test_promote_environment_expired(state_sync: EngineAdapterStateSync, make_sn
882883
)
883884

884885
# This call shouldn't fail.
885-
state_sync.promote(new_environment)
886+
promotion_result = state_sync.promote(new_environment)
887+
assert promotion_result.added == [snapshot.table_info]
888+
assert promotion_result.removed == []
889+
assert promotion_result.removed_environment_naming_info is None
886890

887891

888892
def test_promote_snapshots_no_gaps(state_sync: EngineAdapterStateSync, make_snapshot: t.Callable):

0 commit comments

Comments
 (0)