Updated on 2026-11-06 GMT+08:00

Soft Deleting a Dataset

Syntax

DROP DATASET [IF EXISTS] dataset_name [PURGE]
  • PURGE: The dataset data is deleted.
  • IF EXISTS: If specified, no error is thrown when the dataset does not exist.
  • dataset_name: Name of the dataset to be dropped. If EXISTS is not specified and the dataset is not found, Spark will throw an error.

For managed datasets:

PURGE specified: Updates the metadata entry and moves the underlying data files to the recycle bin.

PURGE not specified: Only updates the metadata entry.

For external datasets:

Only the metadata entry is updated. The underlying files are never deleted. Therefore, specifying PURGE or not has no effect on external datasets.

A soft-deleted dataset can be restored or permanently deleted.

If a dataset exists in a database, dropping the database will fail. When dropping a database, either the database must be empty (containing no datasets), or the cascade parameter must be passed to recursively delete all entities within the database.

Sample Code

DROP DATASET IF EXISTS my_dataset 
DROP DATASET IF EXISTS my_dataset PURGE