Skip to content

Fix: Reporting deletion of physical tables for snapshots of symbolic / audit models#5422

Merged
izeigerman merged 1 commit intomainfrom
fix-dont-report-deletion-of-symbolic-models
Sep 22, 2025
Merged

Fix: Reporting deletion of physical tables for snapshots of symbolic / audit models#5422
izeigerman merged 1 commit intomainfrom
fix-dont-report-deletion-of-symbolic-models

Conversation

@izeigerman
Copy link
Collaborator

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.

@izeigerman izeigerman requested review from a team and Copilot September 22, 2025 20:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.snapshot.is_model already covers this. is_model and is_audit are mutually exclusive. sigh

@izeigerman izeigerman force-pushed the fix-dont-report-deletion-of-symbolic-models branch from 9ac7079 to 4aad9af Compare September 22, 2025 21:01
@izeigerman izeigerman merged commit 6d00e35 into main Sep 22, 2025
44 of 46 checks passed
@izeigerman izeigerman deleted the fix-dont-report-deletion-of-symbolic-models branch September 22, 2025 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants