Skip to content

Commit

Permalink
Revise to use public method
Browse files Browse the repository at this point in the history
  • Loading branch information
themisvaltinos committed Jan 8, 2025
1 parent 6343569 commit 3e4492c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
24 changes: 24 additions & 0 deletions sqlmesh/core/model/definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,30 @@ def render_post_statements(
**kwargs,
)

def render_on_virtual_update(
self,
*,
start: t.Optional[TimeLike] = None,
end: t.Optional[TimeLike] = None,
execution_time: t.Optional[TimeLike] = None,
snapshots: t.Optional[t.Dict[str, Snapshot]] = None,
expand: t.Iterable[str] = tuple(),
deployability_index: t.Optional[DeployabilityIndex] = None,
engine_adapter: t.Optional[EngineAdapter] = None,
**kwargs: t.Any,
) -> t.List[exp.Expression]:
return self._render_statements(
self.on_virtual_update,
start=start,
end=end,
execution_time=execution_time,
snapshots=snapshots,
expand=expand,
deployability_index=deployability_index,
engine_adapter=engine_adapter,
**kwargs,
)

def render_audit_query(
self,
audit: Audit,
Expand Down
6 changes: 2 additions & 4 deletions sqlmesh/core/snapshot/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1251,10 +1251,8 @@ def promote(
column_descriptions=model.column_descriptions if is_prod else None,
view_properties=model.virtual_properties,
)
if on_virtual_update := model.on_virtual_update:
adapter.execute(
model._render_statements(on_virtual_update, engine_adapter=adapter, **kwargs)
)
if model.on_virtual_update:
adapter.execute(model.render_on_virtual_update(engine_adapter=adapter, **kwargs))

def demote(self, view_name: str, **kwargs: t.Any) -> None:
logger.info("Dropping view '%s'", view_name)
Expand Down

0 comments on commit 3e4492c

Please sign in to comment.