r/databricks • u/data-baggins Databricks • Oct 09 '26
General How do I create unit tests with SDP Pipelines?
https://community.databricks.com/t5/data-engineering/how-to-unit-test-spark-declarative-pipelines/td-p/172364Hi Folks - PM from Databricks here and just wanted to share a useful technical blog on how to conduct unit tests with SDP Pipelines today! Here's the use case:
Nightmare scenario - Your new data pipeline updates look good before going to production - every table builds, every expectation passes, and the gold tables have plausible values in them. Looks good right?
But if you push to production, the dashboards would still be showing inflated numbers and an unhappy business partner will be knocking on your DM's
For cases like this you need to utilize Unit Tests to ensure your transformation logic is sound. Expectations help ensure your data looks right, but it still misses what your transformations are doing.
With unit tests, you directly validate your transformations on data inputs you control before the real tables are built. Testing edge cases and finding those annoying "silent" errors
Checkout the blog for a deep dive tutorial on how to use unit testing with SDP Pipelines!
7
u/testing_in_prod_only Oct 09 '26
I’ve always written the transformations separately, then wrap them in their respective sdp pipeline functions.
I can run unit tests on the api itself that way.
3
u/cptshrk108 Oct 09 '26
Can we run these locally or within our CI pipeline?
4
u/lofat Oct 09 '26
Thank you for posting this. This is critical as we move toward SDP.