Skip to content

Commit 84988c3

Browse files
committed
make is_snapshot_deployable optional
1 parent 576b3c1 commit 84988c3

3 files changed

Lines changed: 16 additions & 12 deletions

File tree

examples/custom_materializations/custom_materializations/custom_kind.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def insert(
2929
) -> None:
3030
assert type(model.kind).__name__ == "ExtendedCustomKind"
3131

32-
self._replace_query_for_model(model, table_name, query_or_df, render_kwargs, **kwargs)
32+
self._replace_query_for_model(model, table_name, query_or_df, render_kwargs)

examples/custom_materializations/custom_materializations/full.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ def insert(
2020
render_kwargs: t.Dict[str, t.Any],
2121
**kwargs: t.Any,
2222
) -> None:
23-
self._replace_query_for_model(model, table_name, query_or_df, render_kwargs, **kwargs)
23+
self._replace_query_for_model(model, table_name, query_or_df, render_kwargs)

sqlmesh/core/snapshot/evaluator.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,9 +1954,13 @@ def promote(
19541954
view_properties=model.render_virtual_properties(**render_kwargs),
19551955
)
19561956

1957-
snapshot = kwargs["snapshot"]
1958-
deployability_index = kwargs["deployability_index"]
1959-
is_snapshot_deployable = deployability_index.is_deployable(snapshot)
1957+
snapshot = kwargs.get("snapshot")
1958+
deployability_index = kwargs.get("deployability_index")
1959+
is_snapshot_deployable = (
1960+
deployability_index.is_deployable(snapshot)
1961+
if snapshot and deployability_index
1962+
else False
1963+
)
19601964

19611965
# Apply grants to the physical layer (referenced table / view) after promotion
19621966
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
@@ -2029,7 +2033,7 @@ def create(
20292033

20302034
# Apply grants after table creation (unless explicitly skipped by caller)
20312035
if not skip_grants:
2032-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2036+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
20332037
self._apply_grants(
20342038
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
20352039
)
@@ -2118,7 +2122,7 @@ def _replace_query_for_model(
21182122

21192123
# Apply grants after table replacement (unless explicitly skipped by caller)
21202124
if not skip_grants:
2121-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2125+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
21222126
self._apply_grants(model, name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
21232127

21242128
def _get_target_and_source_columns(
@@ -2409,7 +2413,7 @@ def create(
24092413

24102414
if not skip_grants:
24112415
# Apply grants after seed table creation and data insertion
2412-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2416+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
24132417
self._apply_grants(
24142418
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
24152419
)
@@ -2496,7 +2500,7 @@ def create(
24962500

24972501
if not skip_grants:
24982502
# Apply grants after SCD Type 2 table creation
2499-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2503+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25002504
self._apply_grants(
25012505
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
25022506
)
@@ -2569,7 +2573,7 @@ def insert(
25692573
)
25702574

25712575
# Apply grants after SCD Type 2 table recreation
2572-
is_snapshot_deployable = kwargs["is_snapshot_deployable"]
2576+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25732577
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
25742578

25752579
def append(
@@ -2629,7 +2633,7 @@ def insert(
26292633
)
26302634

26312635
# Apply grants after view creation / replacement
2632-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2636+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
26332637
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
26342638

26352639
def append(
@@ -2651,7 +2655,7 @@ def create(
26512655
skip_grants: bool,
26522656
**kwargs: t.Any,
26532657
) -> None:
2654-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2658+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
26552659

26562660
if self.adapter.table_exists(table_name):
26572661
# Make sure we don't recreate the view to prevent deletion of downstream views in engines with no late

0 commit comments

Comments
 (0)