On a client's Databricks platform, our team loads data from external systems into Delta tables, each writer swapping out one source's rows with replaceWhere. We had partitioned the tables by source so concurrent writers wouldn't collide, and the same partition key fixed the data layout: any layout change meant rewriting the whole table. Deployments and maintenance were the busy times, when a batch run might reload one source or every source while other writers kept going.
So we dropped the partition key. Our writers ran on Runtime 16, and converting a partitioned table to liquid clustering in place needs Runtime 18.1 or above, so we rebuilt the tables in Unity Catalog, clustered by source name and date, with deletion vectors on so Delta Lake checks write conflicts row by row instead of file by file. Since the migration, our single-source reloads and our full reloads have both committed while other writers were running, and the clustering keys can be changed with ALTER TABLE without a table rewrite.
How partitioning gave us file-level concurrency
Our source partition worked as write isolation because of how Delta Lake spots conflicts. Unless row-level concurrency is on, it compares the files each write touched, and the documentation says two operations conflict only when they affect the same files. Partitioning on the columns in each write's condition keeps those files apart, which is exactly what our per-source writes relied on.
That was the mechanism behind our old design. A writer replaced its source with a predicate on the partition column:
# Table partitioned by source_name
(df.write
.mode("overwrite")
.option("replaceWhere", "source_name = 'A'")
.saveAsTable("catalog.schema.events"))
A write for source A rewrote files under source_name=A, and a write for source B rewrote files under source_name=B. The file sets never overlapped, so neither commit failed. replaceWhere also validates that every incoming row satisfies the predicate and fails the write otherwise, which keeps a bad batch from leaking into a neighboring source. That check can be turned off on classic compute, so it only protects you while it stays on.
The same rule explains the awkward case. A replace across all sources overlaps every partition by construction, so partition isolation gave it no protection against any other writer running at that moment.
The partition key had to satisfy two unrelated requirements. It had to be a good read layout, and it had to line up with how writers divided the work. Changing it meant rewriting the table, a point Databricks makes in its row-level concurrency deep dive, so the layout was effectively fixed for as long as the writers depended on it.
Liquid clustering, deletion vectors and row-level concurrency split the job
Liquid clustering took over the layout job. Instead of a folder per source, we declared clustering keys and let Databricks arrange the files around them. Clustering can't be combined with partitioning or ZORDER, so the partition key had to go. Databricks allows up to four keys, and each needs column statistics; we used two.
Deletion vectors change how a row-level change is stored. Without them, modifying one row rewrites the whole Parquet file that holds it. With them, the change is recorded as a soft delete in metadata, and reads apply it at query time.
Row-level concurrency took over the isolation job. It records which rows each write changed, so two writers can share a file as long as they change different rows. Databricks turns it on by itself when three conditions hold: Runtime 14.3 LTS or above, no partitions, and deletion vectors on. Our writers already ran on Runtime 16, and our clustered tables meet the other two conditions.
Under partitioning, a write for source A only touched the files for source A, and a write for source B only touched the files for source B. On the clustered table with deletion vectors, writer A and writer B can change different rows in one shared file, because the deletion vectors record changed rows and the conflict check compares them.
Here is the documented conflict matrix with row-level concurrency enabled:
| Concurrent pair | WriteSerializable (default) | Serializable |
|---|---|---|
| INSERT + INSERT | No conflict | No conflict |
| INSERT + UPDATE/DELETE/MERGE | No conflict | Conflict only on the same row |
| UPDATE/DELETE/MERGE pair | Conflict only on the same row | Conflict only on the same row |
| UPDATE/DELETE/MERGE + OPTIMIZE | No conflict | No conflict |
| INSERT + OPTIMIZE | No conflict | No conflict |
The OPTIMIZE rows carry an exception for ZORDER BY, which doesn't apply because clustered tables can't use it.
What we saw with replaceWhere
The matrix lists INSERT, UPDATE, DELETE, MERGE and OPTIMIZE, and it doesn't list replaceWhere or INSERT OVERWRITE. The selective overwrite page calls REPLACE WHERE atomic but says nothing about how it behaves under concurrency.
On our clustered tables, both paths have worked. Runs that replace one source and runs that replace every source have committed while other writers were running, with no partition key keeping their files apart. That's our result on our writers and predicates, and the documentation doesn't cover it, so treat it as one team's evidence.
The same page documents a behavior that matters for deployment reloads. When the source query is empty, REPLACE WHERE can delete the rows its predicate matches. A replace-all run fed by a failed extract can therefore clear sources it was meant to refresh, so check the incoming batch before the write. If data is overwritten by mistake, a table restore can undo it.
Rebuilding the tables with clustering keys
The in-place conversion command, ALTER TABLE ... REPLACE PARTITIONED BY WITH CLUSTER BY, needs Runtime 18.1 or above. We were on Runtime 16, so we rebuilt each table as a new Unity Catalog managed table with clustering. We chose two keys: source_name, the old partition column that every replaceWhere predicate filters on, and the date column.
CREATE TABLE catalog.schema.events_clustered
CLUSTER BY (source_name, record_date)
AS SELECT * FROM catalog.schema.events;
-- Row-level concurrency depends on this property being true
SHOW TBLPROPERTIES catalog.schema.events_clustered ('delta.enableDeletionVectors');
Liquid clustered tables are created with deletion vectors among their default features, and turning them off disables row-level concurrency, so the property is worth checking on every rebuilt table. Writes that land on the old table during the copy aren't in the new one, so the copy and the switch need a window where those writers are paused or their batches are replayed.
Three things can undo a rebuild like ours, so we'd check them first on any other table. A table with an identity column doesn't support concurrent writes at all. A write whose condition uses structs, arrays, maps, subqueries or non-deterministic expressions goes back to file-level conflict checks, so writers can collide again. And clustered tables need newer Delta protocol versions that can't be downgraded, so every tool that reads them has to support those versions.
We kept the replaceWhere predicates exactly as they were. They still bound what each run replaces, and the row-level conflict check now does the separating that the partition directories used to do.
Keeping the layout with a scheduled OPTIMIZE job
Liquid clustering doesn't cluster everything at write time, so we run a scheduled OPTIMIZE job that clusters the data incrementally. On tables with deletion vectors, OPTIMIZE doesn't conflict with other write operations, so the job doesn't need to be scheduled around deployments or batch windows.
What changed, and what we expect
The change we have felt most is flexibility in the layout. The clustering keys can be changed with ALTER TABLE ... CLUSTER BY, and the writers no longer depend on them for isolation, so the layout can follow how the data is queried. Under partitioning, a new layout meant a full rewrite, and the writers' isolation came with it.
The documentation points to further advantages that follow from the same setup:
- Isolation stops depending on layout. Two writers can share a file and still commit, because the check looks at rows.
- Maintenance alongside writers.
OPTIMIZEandREORGfile rewrites don't conflict with writes on deletion-vector tables. - Cheaper small changes. A single-row update or delete marks a row in metadata and leaves the file in place.
What row-level concurrency still costs
- Same-row conflicts still fail. Two writers that change the same row still collide, and one of them has to run again.
- Soft deletes stay until compaction. Files are physically rewritten only by
OPTIMIZEorREORG TABLE ... APPLY (PURGE). - Conflict detection has a runtime cost. The documentation says it can increase execution time, and that under many concurrent transactions the writer favors latency over conflict resolution.
- Metadata changes conflict with everything. A property or schema change can fail concurrent writes, including inserts.
- The protocol upgrade is one way. Going back to a partitioned layout means rebuilding the table again.
Run your replace paths against a copy first
Our replace-one-source and replace-all runs commit beside other writers on the clustered tables, but the documentation doesn't promise that for replaceWhere. Before you drop a partition key, rebuild one table as a clustered copy and run your own reloads against it while your other writers are active, so you see your own result before production depends on it.
Frequently asked questions
Can a partitioned table get row-level concurrency if I enable deletion vectors?
No, the partition key has to go first, because row-level concurrency only works on tables without partitions. Turning on deletion vectors still helps a partitioned table in one way: its compaction job stops clashing with other writes, so you can run maintenance beside your loads while you plan the rebuild.
How do I change the clustering keys later?
With one table change that names the new columns, which is the flexibility the partition key never gave us. The new keys apply as the regular compaction job runs, but existing files stay where they are until you run a full recluster, which needs Runtime 16.0 or above and can take hours on a large table. Don't add keys you don't need: on tables under 10 TB, extra keys can slow filters on a single column.
How often should the OPTIMIZE job run?
Often enough that new data doesn't sit unclustered for long. For tables with frequent inserts or updates, the clustering documentation suggests every one to two hours. Each run only clusters the data that isn't clustered yet, so runs usually finish quickly.
Should I switch from REPLACE WHERE to REPLACE USING or REPLACE ON?
Consider them if a reload can ever arrive empty, because that's where they differ. With an empty source, REPLACE WHERE might delete data, while REPLACE USING and REPLACE ON do not, according to the selective overwrite documentation. Both work on liquid clustered tables, but they need newer runtimes, so check that page before switching.