Skip to content

Commit 550324b

Browse files
committed
make is_snapshot_deployable optional
1 parent 80290aa commit 550324b

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
@@ -1895,9 +1895,13 @@ def promote(
18951895
view_properties=model.render_virtual_properties(**render_kwargs),
18961896
)
18971897

1898-
snapshot = kwargs["snapshot"]
1899-
deployability_index = kwargs["deployability_index"]
1900-
is_snapshot_deployable = deployability_index.is_deployable(snapshot)
1898+
snapshot = kwargs.get("snapshot")
1899+
deployability_index = kwargs.get("deployability_index")
1900+
is_snapshot_deployable = (
1901+
deployability_index.is_deployable(snapshot)
1902+
if snapshot and deployability_index
1903+
else False
1904+
)
19011905

19021906
# Apply grants to the physical layer (referenced table / view) after promotion
19031907
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
@@ -1970,7 +1974,7 @@ def create(
19701974

19711975
# Apply grants after table creation (unless explicitly skipped by caller)
19721976
if not skip_grants:
1973-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
1977+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
19741978
self._apply_grants(
19751979
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
19761980
)
@@ -2059,7 +2063,7 @@ def _replace_query_for_model(
20592063

20602064
# Apply grants after table replacement (unless explicitly skipped by caller)
20612065
if not skip_grants:
2062-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2066+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
20632067
self._apply_grants(model, name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
20642068

20652069
def _get_target_and_source_columns(
@@ -2350,7 +2354,7 @@ def create(
23502354

23512355
if not skip_grants:
23522356
# Apply grants after seed table creation and data insertion
2353-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2357+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
23542358
self._apply_grants(
23552359
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
23562360
)
@@ -2437,7 +2441,7 @@ def create(
24372441

24382442
if not skip_grants:
24392443
# Apply grants after SCD Type 2 table creation
2440-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2444+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
24412445
self._apply_grants(
24422446
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
24432447
)
@@ -2510,7 +2514,7 @@ def insert(
25102514
)
25112515

25122516
# Apply grants after SCD Type 2 table recreation
2513-
is_snapshot_deployable = kwargs["is_snapshot_deployable"]
2517+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25142518
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
25152519

25162520
def append(
@@ -2570,7 +2574,7 @@ def insert(
25702574
)
25712575

25722576
# Apply grants after view creation / replacement
2573-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2577+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25742578
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
25752579

25762580
def append(
@@ -2592,7 +2596,7 @@ def create(
25922596
skip_grants: bool,
25932597
**kwargs: t.Any,
25942598
) -> None:
2595-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2599+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25962600

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

0 commit comments

Comments
 (0)