A scenario for a data engineer · Mid level and up
Customers keep getting their old address back
Query · Analytics
Monday, 10:15
A feed of customer changes from the source database sometimes arrives out of order. Your Databricks job applies changes to the Delta table as they arrive, so an older update can land on top of a newer one.
What do you do?
Tap the one you would do. The answer opens below.
Show the best callThe best call
Move it to a Lakeflow pipeline's change data capture flow, and tell it which column orders the changes.
Late changes are put in the right order for you. An older update never replaces a newer one.
Why
AUTO CDC in Lakeflow pipelines (once called APPLY CHANGES) applies a change feed to a table. SEQUENCE BY names the column that orders the changes, so records that arrive out of order are handled for you.
Read it in the Databricks docs (opens in a new tab)The other two
- Works, at a price. Write a MERGE that keeps the newest change per customer in each batch and updates only when the change is newer than the row.
- Correct, as long as you got every case right. Deletes, ties and late rows are yours to handle and test.
- A poor call. Sort each batch by arrival time before applying it.
- Arrival time is the problem. A late change still arrives last and still wins.
The words in this scenario
- MERGE.
- One statement that compares new rows with a table by a key: rows that match are updated or deleted, rows that do not are inserted. In the docs (opens in a new tab)
Go deeper on brickster.ai
- LakeFlow: what changed recentlyNews, releases, videos and questions on it, gathered daily.
- Follow Structured StreamingNews, releases, videos and questions on it, gathered daily.
More scenarios
- A stream that waits all day for one delivery · data engineer
- The stream gets slower every week · data engineer
- Where should the new pipeline read from? · data engineer
- All 47 scenarios
Had one like this at work? Send it to us: the best tickets come from real incidents.
Checked against the Databricks documentation on . brickster.ai is independent and is not affiliated with Databricks.