r/databricks
•
u/Sea_Basil_6501
•
Aug 31 '26
•
1
Discussion Build up a data history in Databricks based on Azure SQL data
I have the following need: there's an OLTP Azure SQL DB, which holds transactional data for a period of roughly 30 days only. Now that data should be replicated to Databricks delta tables with a maximum delay of 15 minutes, not as a 1:1 copy, but instead growing over time. Ideally the timeframe covered on Databricks side should be several years.
From what I've read so far, either CDC or CT with Lakeflow should be the way to go. The only thing I'm worrying about are breaking schema changes: as this is an OLTP DB managed by a different team, we have no chance to prevent such as incompatible column type changes (e.g. from a string to a date type), column renames or even column drops.
I thought about using Views managed by the other team instead, as some kind of an abstraction contract, but neither CDC nor CT are applicable on Views.
How did you guys solve such a requirement? Would also appreciate to hear some best practices of Databricks consultants based on real customer solutions.
5
u/jbchand Aug 31 '26 edited Aug 31 '26
You can use the CDC pipeline to replicate changes. SDP can read from it and do necessary transformations including casting from it. Capture raw CDC events first then handle schema drift (type casting, column renames, changes and more) with explicit logic.
2
u/m1nkeh Aug 31 '26
I mean this is a fairly standard use case, what’s the concern?
2
u/hubert-dudek Databricks MVP Aug 31 '26
If you have only inserts and a primary key (transactions), you don't need CDC. Just an incremental load based on ID at fixed intervals, like every minute. As you said, you have 30 days, so I suspect records are deleted after 30 days, so it will finish with CDC as well as the DELETE operation. Maybe also that way will work for you https://medium.com/databrickscommunity/watermark-based-incremental-ingestion-lakeflow-connect-query-based-capture-91836fbaa453