fix(duckdb): do not cascade table/view drops in DuckLake catalogs - #6034
Open
kingjaiteh wants to merge 1 commit into
Open
fix(duckdb): do not cascade table/view drops in DuckLake catalogs#6034kingjaiteh wants to merge 1 commit into
kingjaiteh wants to merge 1 commit into
Conversation
DuckLake does not implement `DROP TABLE ... CASCADE` or `DROP VIEW ... CASCADE` and raises "Cascade Drop not supported in DuckLake". Since SQLMesh#5133 the janitor always deletes snapshot tables with cascade=True, so on a DuckLake catalog it can never reclaim space and silently reports "Cleanup complete." until a snapshot expires. Cascade support is declared per engine adapter, but on DuckDB it varies per attached catalog. Resolve the target catalog's type from duckdb_databases() and omit CASCADE for TABLE/VIEW drops in DuckLake catalogs. SCHEMA cascade is still supported by DuckLake and is left untouched, as is behaviour for native DuckDB catalogs. Fixes SQLMesh#6032 Signed-off-by: kingjaiteh <omarjaiteh453@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DuckLake does not implement
DROP TABLE ... CASCADEorDROP VIEW ... CASCADEand raises "Cascade Drop not supported in DuckLake". Since #5133 the janitor always deletes snapshot tables with cascade=True, so on a DuckLake catalog it can never reclaim space and silently reports "Cleanup complete." until a snapshot expires.Cascade support is declared per engine adapter (
SUPPORTED_DROP_CASCADE_OBJECT_KINDS), but on DuckDB it varies per attached catalog: a native catalog acceptsDROP TABLE ... CASCADE, a DuckLake catalog attached in the same connection does not.Changes:
DuckDBEngineAdapter._drop_objectresolves the target catalog (explicit catalog on the name, else the current one) and looks up itstypeinduckdb_databases(). Forducklakeit drops TABLE/VIEW without CASCADE. SCHEMA drops are untouched, DuckLake supports cascade there._get_catalog_type, which_create_tablealready did inline for the DuckLake partitioning check, so both share it.enable_view_dependencieskeep cascade.The list-only alternative (removing TABLE/VIEW from the DuckDB cascade list) would also fix DuckLake but would regress
enable_view_dependencieson native catalogs, which is what #4767 added it for.Test Plan
test_drop_table_ducklake_no_cascadeattaches a real DuckLake catalog (same setup astest_ducklake_partitioning), creates a table with a dependent view in it and a native table/view inmemory, and drops all four withcascade=True. Fails onmainwith theNotImplementedExceptionabove.test_drop_object_cascade_by_catalog_typeasserts the emitted SQL with a mocked adapter: no CASCADE for DuckLake table/view, CASCADE kept for DuckLake schema and for a native catalog table.tests/core/engine_adapter/test_duckdb.pyandtests/core/test_snapshot_evaluator.pypass on DuckDB 1.5.5, Python 3.12, Windows.Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCO