Table repair feature
The repair_metadata() function provides a self-service recovery path to
recover Iceberg tables that are inaccessible due to missing data files after manual file deletions
in the underlying storage.
To maintain table integrity, you must always interact with Iceberg tables through the engine or
the Iceberg API. For example, to remove partitions, you must use the DROP
PARTITION statement instead of manually deleting directories from the file system, for
example, S3, ADLS, or HDFS).
When you delete files directly from the storage without updating the Iceberg metadata, the table becomes corrupted, causing the subsequent queries to fail with the following error message: Iceberg table [...] cannot be fully loaded due to unavailable files
This issue occurs because the Iceberg manifest files still contain references to data files that no longer exist. If you cannot restore the missing files from a backup or filesystem trash, you can use the command. The following command synchronizes the metadata by removing references to the missing data files, making the table functional again:
ALTER TABLE <table_name> EXECUTE repair_metadata();
