Skip to content

Commit 9ce7ef8

Browse files
committed
make is_snapshot_deployable optional
1 parent 5d83730 commit 9ce7ef8

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
)
@@ -2383,7 +2387,7 @@ def create(
23832387

23842388
if not skip_grants:
23852389
# Apply grants after SCD Type 2 table creation
2386-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2390+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
23872391
self._apply_grants(
23882392
model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable
23892393
)
@@ -2456,7 +2460,7 @@ def insert(
24562460
)
24572461

24582462
# Apply grants after SCD Type 2 table recreation
2459-
is_snapshot_deployable = kwargs["is_snapshot_deployable"]
2463+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
24602464
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
24612465

24622466
def append(
@@ -2516,7 +2520,7 @@ def insert(
25162520
)
25172521

25182522
# Apply grants after view creation / replacement
2519-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2523+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25202524
self._apply_grants(model, table_name, GrantsTargetLayer.PHYSICAL, is_snapshot_deployable)
25212525

25222526
def append(
@@ -2538,7 +2542,7 @@ def create(
25382542
skip_grants: bool,
25392543
**kwargs: t.Any,
25402544
) -> None:
2541-
is_snapshot_deployable: bool = kwargs["is_snapshot_deployable"]
2545+
is_snapshot_deployable = kwargs.get("is_snapshot_deployable", False)
25422546

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

0 commit comments

Comments
 (0)