Skip to main content
The DeleteFiles interface provides an API for removing data files from an Iceberg table.

Overview

DeleteFiles accumulates file deletions, produces a new snapshot of the table, and commits that snapshot as the current. This is used to remove files that are no longer needed or to delete data matching specific criteria.

Interface

Core Methods

deleteFile() with Path

Deletes a file by its path.
Parameters:
  • path - A fully-qualified file path to remove from the table
Returns: This for method chaining Description: To remove a file from the table, this path must exactly match a path in the table’s metadata. Paths that are different but equivalent will not be removed. For example, file:/path/file.avro is equivalent to file:///path/file.avro, but would not remove the latter. Example:

deleteFile() with DataFile

Deletes a file tracked by a DataFile.
Parameters:
  • file - A DataFile to remove from the table
Returns: This for method chaining Example:

deleteFromRowFilter()

Deletes files that match an expression on data rows.
Parameters:
  • expr - An expression on rows in the table
Returns: This for method chaining Throws: ValidationException if a file can contain both rows that match and rows that do not Description: A file is selected to be deleted if it could contain any rows that match the expression (using an inclusive projection). Files are deleted if all rows in the file must match the expression (using a strict projection). Example:

caseSensitive()

Enables or disables case sensitive expression binding.
Parameters:
  • caseSensitive - Whether expression binding should be case sensitive
Returns: This for method chaining Example:

validateFilesExist()

Enables validation that deleted files still exist when committing.
Returns: This for method chaining Description: Validates that any files being deleted are still part of the table when the operation commits. This prevents issues from concurrent modifications. Example:

Examples

Delete Single File

Delete Multiple Files

Delete Files from Scan

Delete Partition

Delete Multiple Partitions

Delete with Validation

Conditional Delete

Delete Small Files

Delete with Time-Based Filter

Incremental Delete Pattern

Case-Insensitive Delete

Safe Delete with Error Handling

Important Notes

Path Matching

Paths must match exactly:

Atomic Operations

All deletions are atomic:

Expression-Based Deletion

Files are only deleted if all rows match:

See Also