Fix: Reporting deletion of physical tables for snapshots of symbolic / audit models#5422
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an issue where SQLMesh incorrectly reported deletion of physical tables for symbolic and audit model snapshots, even though these types don't have physical tables to delete. This was causing user confusion and alarm.
- Filters out symbolic and audit snapshots from cleanup operations
- Adds test coverage to verify callbacks are not triggered for these snapshot types
- Updates existing tests to verify the correct number of cleanup callbacks
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| sqlmesh/core/snapshot/evaluator.py | Added filtering logic to skip symbolic and audit snapshots in cleanup method |
| tests/core/test_snapshot_evaluator.py | Added test for symbolic/audit cleanup behavior and updated existing test assertions |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| on_complete: A callback to call on each successfully deleted database object. | ||
| """ | ||
| target_snapshots = [ | ||
| t for t in target_snapshots if t.snapshot.is_model and not t.snapshot.is_symbolic |
There was a problem hiding this comment.
The filter condition is incomplete. Audit snapshots should also be excluded from cleanup operations based on the PR description, but the current condition only filters out symbolic snapshots. The condition should be t.snapshot.is_model and not t.snapshot.is_symbolic and not t.snapshot.is_audit or similar to properly exclude both symbolic and audit snapshots.
| t for t in target_snapshots if t.snapshot.is_model and not t.snapshot.is_symbolic | |
| t for t in target_snapshots if t.snapshot.is_model and not t.snapshot.is_symbolic and not t.snapshot.is_audit |
There was a problem hiding this comment.
t.snapshot.is_model already covers this. is_model and is_audit are mutually exclusive. sigh
9ac7079 to
4aad9af
Compare
Seeing SQLMesh reporting deletion of external tables confuses and terrifies users, even though no actual deletion occurred. This PR fixes the reporting so that symbolic and audit snapshots are skipped entirely.