Skip to content

Commit 2590a5c

Browse files
committed
make is_snapshot_deployable optional
1 parent 6be1a38 commit 2590a5c

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

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
@@ -1847,9 +1847,13 @@ def promote(
18471847
view_properties=model.render_virtual_properties(**render_kwargs),
18481848
)
18491849

1850-
snapshot = kwargs["snapshot"]
1851-
deployability_index = kwargs["deployability_index"]
1852-
is_snapshot_deployable = deployability_index.is_deployable(snapshot)
1850+
snapshot = kwargs.get("snapshot")
1851+
deployability_index = kwargs.get("deployability_index")
1852+
is_snapshot_deployable = (
1853+
deployability_index.is_deployable(snapshot)
1854+
if snapshot and deployability_index
1855+
else False
1856+
)
18531857

18541858
# Apply grants to the physical layer (referenced table / view) after promotion
18551859
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
@@ -1916,7 +1920,7 @@ def create(
19161920

19171921
# Apply grants after table creation (unless explicitly skipped by caller)
19181922
if not skip_grants:
1919-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
1923+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
19201924
self._apply_grants(
19211925
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
19221926
)
@@ -2005,7 +2009,7 @@ def _replace_query_for_model(
20052009

20062010
# Apply grants after table replacement (unless explicitly skipped by caller)
20072011
if not skip_grants:
2008-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2012+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
20092013
self._apply_grants(model, name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
20102014

20112015
def _get_target_and_source_columns(
@@ -2296,7 +2300,7 @@ def create(
22962300

22972301
if not skip_grants:
22982302
# Apply grants after seed table creation and data insertion
2299-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2303+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
23002304
self._apply_grants(
23012305
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
23022306
)
@@ -2371,7 +2375,7 @@ def create(
23712375

23722376
if not skip_grants:
23732377
# Apply grants after SCD Type 2 table creation
2374-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2378+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
23752379
self._apply_grants(
23762380
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
23772381
)
@@ -2444,7 +2448,7 @@ def insert(
24442448
)
24452449

24462450
# Apply grants after SCD Type 2 table recreation
2447-
is_snapshot_deployable = kwargs["is_snapshot_deployable"]
2451+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
24482452
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
24492453

24502454
def append(
@@ -2504,7 +2508,7 @@ def insert(
25042508
)
25052509

25062510
# Apply grants after view creation / replacement
2507-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2511+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25082512
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
25092513

25102514
def append(
@@ -2526,7 +2530,7 @@ def create(
25262530
skip_grants: bool,
25272531
**kwargs: t.Any,
25282532
) -> None:
2529-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2533+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25302534

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

0 commit comments

Comments
 (0)