2 weeks ago
Hi,
Would appreciate some support on the DELTA_CLONE_INCOMPLETE_FILE_COPY issue with DEEP CLONE.
Exact error is as follows:
An error occurred while calling o459.sql.
: org.apache.spark.SparkException: Job aborted due to stage failure: Task 144 in stage 180.0 failed 4 times, most recent failure: Lost task 144.3 in stage 180.0 (TID 2654) (10.64.143.31 executor 0): com.databricks.sql.transaction.tahoe.DeltaIOException: [DELTA_CLONE_INCOMPLETE_FILE_COPY] File (abfss://data@...) not copied completely. Expected file size: 146660, found: 0. To continue with the operation by ignoring the file size check set `spark.databricks.delta.clone.checkWrite` to false.
---
There are indeed parquet files with 0 bytes on primary.
It also seems like copying is successful if we would compare primary counts with the secondary ones.
Not sure setting `spark.databricks.delta.clone.checkWrite` to false is a proper approach here.
DBR is 14.3
Thank you
2 weeks ago
Hi @YuriS
The clone is working as intended. The problem is in the source table. The Delta log says that file is 146,660 bytes, but on primary storage it's 0 bytes, so the source table already points at a truncated/corrupt parquet file. Don't set checkWrite to false. That would just copy the broken file to the secondary. Find the 0-byte files that are still active in the table, repair them on the source, then re-run the clone.
Why the counts match: COUNT(*) on a Delta table is answered from the row counts stored in the transaction log, so it never opens the file. Reading the actual data will fail. You can check with:
SELECT count(*) FROM parquet.`abfss://<container>@<account>.dfs.core.windows.net/<table_path>/<the_file>.parquet`
1. List the active files that are empty:
tbl = "catalog.schema.table"
loc = spark.sql(f"DESCRIBE DETAIL {tbl}").first()["location"]
active = set(spark.table(tbl).inputFiles())
empty = (spark.read.format("binaryFile").option("recursiveFileLookup", "true")
.option("pathGlobFilter", "*.parquet").load(loc)
.filter("length = 0").select("path").collect())
bad = [r.path for r in empty if r.path in active]
print(len(bad), bad[:20])
2. Repair on the source:
- If ADLS blob versioning or soft delete is enabled on the account, restore the previous version of each of those blobs. This is the cleanest fix because no data is lost.
- If not, the rows in those files are gone. Rebuild the affected partition from upstream, or remove the bad files from the table and reload just those rows (delete the 0-byte files, run FSCK REPAIR TABLE catalog.schema.table, which drops log entries for missing files, then backfill).
3. Re-run the DEEP CLONE. It's incremental, so it only copies what's missing.
It's also worth finding out what wrote those 0-byte files (a storage copy/replication job, a lifecycle policy, or a manual restore). Healthy Delta writes never commit an empty file, so something outside Spark probably changed them.
2 weeks ago
Hi @YuriS possible to stop your parent job and then execute deep copy?
2 weeks ago
Source File Corruption: The Delta transaction log expects a valid Parquet file (e.g., 146660 bytes), while the actual file on your primary storage is 0 bytes. DEEP CLONE is failing intentionally to prevent propagating corrupted data.
Why Row Counts Match: Running SELECT COUNT(*) on a Delta table reads metadata statistics directly from the transaction log rather than opening the underlying Parquet files. Attempting to query the actual data inside those specific files will fail.
Identify the Active 0-Byte Files Run the following PySpark snippet to find which 0-byte files are currently referenced as active in your source table's transaction log:
tbl = "catalog.schema.table" loc = spark.sql(f"DESCRIBE DETAIL {tbl}").first()["location"] active = set(spark.table(tbl).inputFiles()) empty = (spark.read.format("binaryFile") .option("recursiveFileLookup", "true") .option("pathGlobFilter", "*.parquet") .load(loc) .filter("length = 0") .select("path") .collect()) bad_files = [r.path for r in empty if r.path in active] print(f"Found {len(bad_files)} active 0-byte files:", bad_files[:20])
(If bad_files is empty, the 0-byte files are unreferenced/orphaned files and can be cleaned up with VACUUM, though DEEP CLONE only fails if they are active in the log).
Repair the Source Table
Option A (No Data Loss โ Storage Versioning): If Azure Data Lake Storage (ADLS) blob versioning or soft delete is enabled, restore the previous non-empty versions of the affected .parquet files.
Option B (Rebuild / Backfill): If previous versions aren't available, the data in those specific files is lost. Delete the 0-byte files from storage, run FSCK REPAIR TABLE catalog.schema.table to remove the missing file references from the Delta log, and backfill the missing partitions from your upstream source.
Investigate the Root Cause & Re-run Clone
Healthy Spark/Delta commits do not create 0-byte files. Check if an external process (e.g., an AzCopy/storage replication job, lifecycle policy, or concurrent non-Delta overwrite) truncated the files. Ensure any parent ingestion job is paused if concurrent modifications are interfering.
Once the source table is healthy, re-run your DEEP CLONE commandโsince it operates incrementally, it will resume and copy only the remaining valid files.
2 weeks ago
Short answer: I wouldn't set spark.databricks.delta.clone.checkWrite to false. That check is a safety net. DEEP CLONE compares the size of each file it wrote against the size recorded in the source table's transaction log. Expected 146660 and found 0 means the file you ended up with is empty even though Delta believes it has data. Disabling the check would just give you a "successful" clone with a broken file in it.
Why the matching counts don't prove anything
A plain SELECT COUNT(*) on a Delta table is typically answered from the per-file statistics (numRecords) in the transaction log, without opening the Parquet files. So the counts can match on both sides while a file is physically empty. Run something that actually reads the data (for example SELECT * on the affected files, or a column aggregate with no stats shortcut) and I'd expect it to fail on that file.
Work out which side has the empty file
You said there are 0-byte Parquet files on the primary, so I'd treat the source as the prime suspect.
display(dbutils.fs.ls("abfss://data@<account>.dfs.core.windows.net/<table_path>/<partition>/"))
add actions from _delta_log and look at the recorded sizes:
from pyspark.sql.functions import col
log = spark.read.json("abfss://data@<account>.dfs.core.windows.net/<table_path>/_delta_log/*.json")
adds = log.where("add is not null").select(col("add.path").alias("path"), col("add.size").alias("size"))
adds.where("path like '%<file_name_fragment>%'").show(truncate=False)
Then list the actual storage sizes and join them against adds. Anything where the log says N bytes and storage says 0 is a damaged file.DESCRIBE HISTORY on the source. Check whether the file belongs to the version you're cloning, or whether a later version already replaced it. If you're cloning a specific VERSION AS OF or TIMESTAMP AS OF, try cloning the latest version instead.If the source file really is 0 bytes but referenced in the log
The source table is corrupted. That usually means something other than Delta touched the files: an external copy job (AzCopy, ADF, a replication or sync process between "primary" and "secondary" storage), a failed or interrupted write, or a manual cleanup. Delta relies on the transaction log being the only thing that adds, changes or removes data files, and modifying files outside it can cause lost data or table corruption [1].
If the source is fine and the empty file shows up only on the target
That points to a transient problem during the copy. Check for storage throttling or firewall/networking issues on the destination account, and check that the cluster's identity has write access to the target container. Then drop or clean up the partial target and re-run. Note that your task already failed four times, so the failure looks deterministic rather than a one-off blip.
When checkWrite=false is acceptable
Only if you've confirmed the files are legitimately empty and the log is wrong, and you accept that the target will carry the same inconsistency. In that situation I'd still fix the source rather than propagate the problem.
Once the source is clean, re-run the clone. DEEP CLONE makes a complete, independent copy of the table [2], and if it's an incremental refresh you can re-issue the same CREATE OR REPLACE TABLE ... DEEP CLONE statement:
CREATE OR REPLACE TABLE target_catalog.target_schema.target_table
DEEP CLONE source_catalog.source_schema.source_table;
[1] Best practices: Delta Lake - Azure Databricks | Microsoft Learn โ https://learn.microsoft.com/en-us/azure/databricks/delta/best-practices
[2] CREATE TABLE CLONE - Azure Databricks - Databricks SQL | Microsoft Learn โ https://learn.microsoft.com/en-us/azure/databricks/sql/language-manual/delta-clone
Friday
DELTA_CLONE_INCOMPLETE_FILE_COPY indicates that Delta could not verify a complete copy of a source data file.
I would not disable spark.databricks.delta.clone.checkWrite because that could allow incomplete data to go undetected.
My recommended checks are:
Identify the exact source file from the exception.
Verify that the source object exists and is readable.
Confirm that the destination storage has sufficient permissions and capacity.
Inspect the underlying ADLS error for timeouts, throttling or access failures.
Check whether the failure consistently references the same file.
For example, if the clone always fails on one Parquet file, investigate that object and its source accessibility before retrying the entire operation.
If different files fail across attempts, investigate transient storage connectivity or throttling.
I would also avoid manually copying files into the Delta destination because that can leave the table in an inconsistent state.
Could you confirm whether retries fail on the same source file and whether the underlying exception contains an HTTP status code?
That information would help narrow down the failure before changing any Delta settings.