Skip to content

Commit 38159c9

Browse files
cnahed-kplerStuffbyYuki
authored andcommitted
Fix: load materializations before run janitor
1 parent c5d008b commit 38159c9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

sqlmesh/core/context.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,8 @@ def run(
784784
Returns:
785785
True if the run was successful, False otherwise.
786786
"""
787+
self._load_materializations()
788+
787789
environment = environment or self.config.default_target_environment
788790
environment = Environment.sanitize_name(environment)
789791
if not skip_janitor and environment.lower() == c.PROD:
@@ -796,7 +798,6 @@ def run(
796798
engine_type=self.snapshot_evaluator.adapter.dialect,
797799
state_sync_type=self.state_sync.state_type(),
798800
)
799-
self._load_materializations()
800801

801802
env_check_attempts_num = max(
802803
1,
@@ -888,6 +889,7 @@ def _has_environment_changed() -> bool:
888889

889890
@python_api_analytics
890891
def run_janitor(self, ignore_ttl: bool, force_delete: bool = False) -> bool:
892+
self._load_materializations()
891893
success = False
892894

893895
if self.console.start_cleanup(ignore_ttl):
@@ -2884,6 +2886,8 @@ def _destroy(self) -> bool:
28842886
self.state_sync.invalidate_environment(name=environment.name, protect_prod=False)
28852887
self.console.log_success(f"Environment '{environment.name}' invalidated.")
28862888

2889+
self._load_materializations()
2890+
28872891
# Run janitor to clean up all objects
28882892
self._run_janitor(ignore_ttl=True)
28892893

0 commit comments

Comments
 (0)