Skip to content

Commit a8038da

Browse files
committed
Fix: load materializations before run janitor
1 parent 6e69ce6 commit a8038da

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

sqlmesh/core/context.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,8 @@ def run(
781781
Returns:
782782
True if the run was successful, False otherwise.
783783
"""
784+
self._load_materializations()
785+
784786
environment = environment or self.config.default_target_environment
785787
environment = Environment.sanitize_name(environment)
786788
if not skip_janitor and environment.lower() == c.PROD:
@@ -793,7 +795,6 @@ def run(
793795
engine_type=self.snapshot_evaluator.adapter.dialect,
794796
state_sync_type=self.state_sync.state_type(),
795797
)
796-
self._load_materializations()
797798

798799
env_check_attempts_num = max(
799800
1,
@@ -885,6 +886,8 @@ def _has_environment_changed() -> bool:
885886

886887
@python_api_analytics
887888
def run_janitor(self, ignore_ttl: bool) -> bool:
889+
self._load_materializations()
890+
888891
success = False
889892

890893
if self.console.start_cleanup(ignore_ttl):
@@ -2873,6 +2876,8 @@ def _destroy(self) -> bool:
28732876
self.state_sync.invalidate_environment(name=environment.name, protect_prod=False)
28742877
self.console.log_success(f"Environment '{environment.name}' invalidated.")
28752878

2879+
self._load_materializations()
2880+
28762881
# Run janitor to clean up all objects
28772882
self._run_janitor(ignore_ttl=True)
28782883

0 commit comments

Comments
 (0)