FSCK REPAIR TABLE

Detects and repairs metadata inconsistencies by removing transaction log entries that reference data files no longer present in the underlying storage.

Category: systemDeltaForge extension

Syntax

FSCK REPAIR TABLE <table> [DRY RUN]

Description

## Overview FSCK REPAIR TABLE scans the Delta transaction log for file entries that reference data files (Parquet files) which no longer exist in the underlying storage. When files have been deleted outside of Delta operations (e.g., manual deletion, storage lifecycle policies, or external tooling), the transaction log becomes inconsistent, causing query failures when the engine attempts to read the missing files. ## Behavior The command operates in two modes: ### DRY RUN Mode The engine scans all file entries in the current snapshot and checks whether each referenced data file exists in storage. It reports the total files checked, the count of files that would be removed, and the estimated bytes freed. No changes are written to the transaction log. ### Repair Mode (default) The engine performs the same scan as DRY RUN, then writes a new commit to the transaction log that removes the entries for missing files. After repair, subsequent queries will no longer attempt to read the missing files. The execution result message reports: - **files_checked**: Total file entries examined in the transaction log. - **files_removed**: Number of entries removed (referencing missing files). - **bytes_removed**: Estimated total size of the missing files based on log metadata. ## Compatibility FSCK REPAIR TABLE follows the same syntax and semantics as the Delta Lake FSCK REPAIR TABLE command. The DRY RUN option provides a safe preview mechanism before committing repairs.

Parameters

NameTypeDescription
tableSpecifies the name or path of the Delta table to check and repair. The table must be registered in the session via CREATE DELTA TABLE or OPEN DELTA TABLE. Fully qualified names (zone.schema.table) are supported.
dry_runIf true, only lists files that would be removed.

Examples

-- Preview which log entries reference missing files
FSCK REPAIR TABLE warehouse.sales.orders DRY RUN;
-- Repair the table by removing orphaned log entries
FSCK REPAIR TABLE warehouse.sales.orders;
-- Repair a table registered by path
FSCK REPAIR TABLE staging.temp.import_data;
-- Dry run on a fully qualified table
FSCK REPAIR TABLE gold.analytics.revenue DRY RUN;

Pitfalls

See Also

Open in interactive docs →   DeltaForge home →