Removes a Delta table from the session and catalog. Optionally deletes the underlying physical data files.
DROP DELTA TABLE [IF EXISTS] <table> [WITH FILES]
## Overview Removes a Delta table from the DataFusion session and the SQLite catalog. By default, only the metadata registration is removed; the physical Delta files on storage are preserved. When WITH FILES is specified, the command also deletes all data files, the `_delta_log/` directory, and any empty parent directories. ## Behavior 1. **Resolve path**: If WITH FILES is specified, the table's storage path and engine are resolved before deregistration. The path is looked up from the session's table_paths registry first; if not found, the catalog is consulted as a fallback. 2. **Deregister from session**: The table is removed from the DataFusion session so it can no longer be referenced in SQL. 3. **Remove from catalog**: For 3-part qualified names, the table entry is removed from the SQLite catalog via the CatalogRouter. 4. **Delete files** (WITH FILES only): The physical files at the resolved path are deleted. For cloud storage (S3, Azure, GCS), the object store API is used. For local paths, standard filesystem operations are used. Empty parent directories are cleaned up. - If IF EXISTS is specified and the table is not found in either the session or the catalog, the command succeeds silently. - Without IF EXISTS, a missing table causes an error. - If WITH FILES is specified but the path cannot be resolved (table not in session or catalog), a warning is logged and the metadata is still removed, but files may remain on storage. ## Compatibility DROP DELTA TABLE is a standard operation. The table's Delta log and data files are unmodified unless WITH FILES is specified. Other Delta clients can still read the table at its storage path after a metadata-only drop.
| Name | Type | Description |
|---|---|---|
table | Fully qualified table name (zone.schema.table) or registered table name. | |
if_exists | Don't error if table doesn't exist. | |
with_files | Also delete physical Delta files. |
-- Drop a table from the session and catalog (metadata only)
DROP DELTA TABLE warehouse.sales.staging_orders;
-- Drop a table only if it exists
DROP DELTA TABLE IF EXISTS warehouse.sales.temp_data;
-- Drop a table and delete all physical files
DROP DELTA TABLE warehouse.sales.old_archive WITH FILES;
-- Drop with both guards
DROP DELTA TABLE IF EXISTS warehouse.sales.deprecated_table WITH FILES;