Troubleshoot and roll back managed table conversions
This page describes how to resolve common ALTER TABLE ... SET MANAGED failures and how to roll back a converted table to an external or foreign table. To convert a table, see Convert external or foreign Delta Lake tables to Unity Catalog managed tables.
Troubleshoot conversion failures
This section describes how to resolve common issues when converting external tables to Unity Catalog managed tables using SET MANAGED.
VERSIONED_CLONE_INTERNAL_ERROR.EXISTING_FILE_VALIDATION_FAILED
If the conversion fails, always retry using the same Databricks Runtime version. Metadata can be serialized differently across versions, which causes a VERSIONED_CLONE_INTERNAL_ERROR.EXISTING_FILE_VALIDATION_FAILED failure if you retry a conversion on a different Databricks Runtime version.
Cluster shutdown during conversion
If your cluster shuts down during conversion, the command might fail with DELTA_ALTER_TABLE_SET_MANAGED_INTERNAL_ERROR. Retry the command to resume the conversion.
Corrupted external table
If the external table is already corrupted (for example, not valid table state), the conversion might fail with errors such as DELTA_TRUNCATED_TRANSACTION_LOG, DELTA_TXN_LOG_FAILED_INTEGRITY, or DELTA_STATE_RECOVER_ERROR. Before attempting conversion, verify that you can run basic operations on the external table, such as DESCRIBE DETAIL.
File validation failure
The SET MANAGED command validates that it copied all files in the latest snapshot of the table to the new managed table location. If any files are missing, the command fails with a DELTA_ALTER_TABLE_SET_MANAGED_FAILED.FILE_VALIDATION_FAILED error.
To resolve this issue:
- Check your Spark driver logs to identify which files could not be migrated.
- Verify that these files exist at the source external table location and are accessible.
- Retry the
ALTER TABLE ... SET MANAGEDcommand.
If the issue persists, contact Databricks support.
Roll back a managed table conversion
Rollback commands require Serverless compute or Databricks Runtime 17.3 LTS and above.
External table
After converting an external table to a managed table, you can roll back within 14 days by using the UNSET MANAGED command. This updates the table metadata to point back to the original external location. Databricks preserves all writes made to the managed location after conversion.
To roll back to an external table, run the following command:
ALTER TABLE catalog.schema.my_managed_table UNSET MANAGED;
Keep the following information in mind:
- If the rollback command is interrupted or fails, rerun it to retry.
- You must restart your streaming jobs after rolling back, similar to conversion.
- Commits made to the managed location between conversion and rollback allow time travel by version, not by timestamp.
- Seven days after rollback, Databricks automatically deletes data in the managed location.
Foreign table: MOVE
You must run UNSET MANAGED before dropping the managed table. Dropping the table without running UNSET MANAGED first might result in data loss or inconsistencies.
To roll back the table migration and regain access to the source table in the external catalog, first roll back the table to an external table with UNSET MANAGED. Then drop the external table to re-federate it as a foreign table.
-
To roll back to an external table, run the following command:
SQLALTER TABLE catalog.schema.my_managed_table UNSET MANAGED -
To re-federate the table to a foreign table, drop the external table with the following command:
SQLDROP TABLE catalog.schema.my_managed_table
The foreign table is available after the next catalog sync.
Keep the following information in mind:
- For commits that you made to the managed location between conversion and rollback, you can time travel by version, not by timestamp.
- Seven days after rollback, Databricks deletes data in the managed location.
Foreign table: COPY
UNSET MANAGED isn't supported for tables converted with COPY. If you run it, the command fails with MIGRATION_ROLLBACK_NOT_SUPPORTED. The conversion left the source table in the external catalog unmodified, so to roll back, drop the managed table. Databricks re-federates it as a foreign table after the next catalog sync.
Verify rollback
Verify rollbacks differently for external and foreign tables.
Verify an external table rollback
To verify that your managed table rolled back to an external table successfully, check whether the table Type is EXTERNAL. You can do either of the following:
-
Open a new tab and go to the Catalog Explorer. In the Details tab, under About this table, the table Type displays as External.
-
Check the table
Typeby running the following SQL command:SQLDESCRIBE EXTENDED catalog_name.schema_name.table_nameTo check multiple tables in one query or script the check, query
information_schema.tablesinstead:SQLSELECT table_type FROM system.information_schema.tablesWHERE table_catalog = 'catalog_name' AND table_schema = 'schema_name' AND table_name = 'table_name';
Verify a foreign table rollback
To verify that your managed table rolled back to a foreign table successfully, check whether the table Type is FOREIGN. You can do either of the following:
-
Open a new tab and go to the Catalog Explorer. In the Details tab, under About this table, the table Type displays as Foreign.
-
Check the table type by running the following SQL command:
SQLSELECT table_type FROM system.information_schema.tablesWHERE table_catalog = 'catalog_name' AND table_schema = 'schema_name' AND table_name = 'table_name';The
table_typecolumn displays asFOREIGN.
Don't use DESCRIBE EXTENDED to verify foreign table conversions or rollbacks. Federation uses hive_metastore catalog behavior for this command, so it shows the table Type as EXTERNAL, regardless of the table's actual state.