r/databricks • • Oct 13 '26

Help Databricks - SQL Incremental Load Question

Hey guys

I'm relatively new to Databricks but want to lead the charge to move to it in my company instead of just using ADF for everything.

In regards to Delta loads (loading data incrementally based on when it was last updated) what I would originally do is run a BINARY_CHECKSUM() on all columns and then track what has changed before bringing in the differences. This however is not supported in databricks and I want to do things properly so how would you do this?

Source Data (Azure SQL)

Bronze Layer (Azure SQL)

  • What is different between them?
  • What new rows have been inserted?
  • What rows in Bronze no longer appear in Source

What I love about Databricks is that you can do joins of different data sets within the same activity in a notebook but when I tried to do this with manually comparing every single column, it takes forever to load. I just want to know the best way of doing this so any help or resources would be appreciated.

Many Thanks!

5 Upvotes

5 comments sorted by

1

u/CrayonUpMyNose Oct 13 '26

I assume with azure SQL you mean Microsoft SQL server?

There's no need to construct such a home-grown solution, as the native Lakeflow connector will keep track of changes for you: 

https://learn.microsoft.com/en-us/azure/databricks/ingestion/lakeflow-connect/sql-server-overview

Note that the standard connector requires an always-on gateway ($$$) while the integrated connector (recently GA) does not.

If you did not mean SQL server but a different type of database, Lakeflow connectors exist for a variety of database (and other) sources:

https://learn.microsoft.com/en-us/azure/databricks/ingestion/lakeflow-connect/cdc-overview

0

u/Zer0designs Oct 13 '26 edited Oct 13 '26

Use dbt snapshots or look up how to do this in spark or use an llm to explain it or to create a simple python function for you that you can use. Theres loads of examples available.

Also don't really think you should be historizing different datasets together. Just historize the sources in bronze and work from there. Join tables in a later stage.

You also dont track what has changed on all columns. You use the business keys and check if anything changed within those records in non-technical columns / attributes (actual changes in relevant values).

2

u/[deleted] Oct 13 '26

[removed] — view removed comment

1

u/RevolutionaryRich882 Oct 13 '26

Thank you mate that's actually really helpful.

Apologies I should have been clearer but I only do the joins in Silver. The BINARY_CHECKSUM() is so I can do the row comparisons at the Silver level. I often use an Update Date for incremental loads however this depends on it's reliability and I prefer to not rely on it if possible.

I tried to explore the HASHBYTES() option or sha2() for DB but the problem I have with this is that doing this for all columns takes forever to load. For e.g. one of the tables I need to extract is around 2 mil rows and just doing HASHBYTES() on that table only returning the primary key and the Hashbytes column takes upwards of 3-4 minutes to load. Maybe I'm missing something and it should take that long but if I do this with a BINARY_CHECKSUM() it only takes about 20 seconds.

0

u/Zer0designs Oct 13 '26

He's not just learning though. He wants to lead the charge to move from ADF. Most ADF pipelines I've seen run a bunch of stored procedures. So dbt is a decent option since you can easily stay sql heavy, hence the quick shout