Skip to content

Fix DuckDB DELETE/UPDATE on view-backed tables#639

Merged
sgrebnov merged 1 commit intospiceai-52from
sgrebnov/0501-duckdb-delete-improve
May 1, 2026
Merged

Fix DuckDB DELETE/UPDATE on view-backed tables#639
sgrebnov merged 1 commit intospiceai-52from
sgrebnov/0501-duckdb-delete-improve

Conversation

@sgrebnov
Copy link
Copy Markdown
Collaborator

@sgrebnov sgrebnov commented May 1, 2026

Fixes Binder Error: Can only delete from base table! when running DELETE or UPDATE against a DuckDB-accelerated table that was created via overwrite mode.

After an InsertOp::Overwrite, DuckDB exposes data through a view over an internal _data* table. The delete_from implementations used the table definition name directly, which resolves to the view — DuckDB rejects DML on views.

Changes:

  1. Add TableDefinition::resolve_dml_table_name() that resolves to the underlying __data_* table when one exists, otherwise returns the base table name (reuses existing list_internal_tables logic)
  2. Update DuckDBDeletionSink and DuckDBUpdateSink to resolve the actual table name at execution time
  3. Add 3 regression tests: filtered delete, delete-all, and filtered update on view-backed tables

@sgrebnov sgrebnov enabled auto-merge (squash) May 1, 2026 13:18
@sgrebnov sgrebnov merged commit 915f038 into spiceai-52 May 1, 2026
12 checks passed
@sgrebnov sgrebnov deleted the sgrebnov/0501-duckdb-delete-improve branch May 1, 2026 13:37
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.

2 participants