Some sources resend every row for a region, an account or a file whenever one of them changes, and we'd stop folding those into a table with AUTO CDC or a hand-written merge now that a flow exists for them. REPLACE USING flows became generally available on 1 December 2026 in Lakeflow pipelines and for standalone streaming tables defined in SQL, on Databricks Runtime 18.2 and above.
Our worry is quiet data loss. Two choices decide what survives each load, the key columns and the SEQUENCE BY column, and choosing either at the wrong grain drops rows or piles them up without a failed update to warn anyone.
Take a store price feed #
Take a feed where each store's system drops a file holding its whole price list whenever any price in it changes. We'd key the flow on store_id and sequence it by an export number the store's system writes onto every row of the file, rising with each file that store sends.
Each half of that design blocks a different loss.
Suppose someone keys it one level finer, on store_id and sku, so it looks like a primary key. Delisted products never leave. The new file has no row for them, and keys missing from an update are left untouched.
Closed stores keep their last price list under either key, for the same reason. If the business needs closed stores gone, we'd ask the source for full snapshots and use AUTO CDC FROM SNAPSHOT, which compares snapshots to determine changes. If stores only go quiet, we'd alert on any store whose latest file is older than its usual interval, alongside the table-level freshness checks in the observability chapter, since one stale store hides easily inside a table that's otherwise current.
Sequencing by each row's price_updated_at loses rows the other way. Only the highest sequence for a key is applied, so the prices edited most recently land and the rest of that store's list is dropped. We'd expect this one to get through code review, because a per-row timestamp looks like the obvious sequence column.
What we'd ask of the loader #
The export number has to come from the store's system, stamped before the file leaves it. A number the ingest job assigns on arrival orders files by when they landed, so a delayed older file would replace a newer list, which is the out-of-order case the sequence column is there to stop.
Rows that share a key and a sequence are all kept, which is how a store's list survives as one group. It's also why we'd reject a store that sends two files under one number, since rows that tie on key and sequence are kept as duplicates.
We'd put an expect_or_fail on the export number too, since a null sequence can lead to undefined behaviour. Bad prices are harder. A drop expectation treats a dropped row as if the source never produced it, so on a group-keyed table we'd expect the file's remaining rows to replace the store's list without that product, which then disappears from the target until the next file. We'd fail the update instead and keep the old list visible while someone fixes the file.
Cutting over from a merge #
The merge this replaces is code we'd be glad to delete. Its delete-then-insert per store becomes the key, and its guard against a late, older file becomes the sequence.
It can't be switched in place, though. A REPLACE USING target has to be created within the pipeline and takes no other flow beside it, so we'd build the new table next to the old one, as a standalone streaming table with the BY NAME the SQL form requires:
CREATE OR REFRESH STREAMING TABLE store_prices_current
FLOW REPLACE USING (store_id) SEQUENCE BY export_id BY NAME
SELECT store_id, sku, price, export_id
FROM STREAM(raw.store_price_files);Before any report reads it, we'd compare row counts per store between the two tables after each load. A store whose count drifts points at a key at the wrong grain or a sequence that ties, before a reader finds it in a report. Store totals then go in a table downstream, because the flow's query can't aggregate.