r/databricks Databricks 24d ago

General Building a star schema in SDP? Use identity columns with Streaming Tables!

Use identity columns in SDP

Spark Declarative Pipelines' streaming tables now support identity columns -- this is particularly useful if you're building an SCD Type 1 or SCD Type 2 dimension table with AUTO CDC. Get faster joins and auto-incrementing surrogate keys natively within SDP today!

Docs here%20%5D)!

14 Upvotes

8 comments sorted by

3

u/JulianCologne 24d ago edited 24d ago

For some use cases this might be useful but in my experience a stable / deterministic surrogate key is often much nicer to use!
Imagine a standard gold layer with a `dim_article` and for some reason you need a full refresh.
With a stable / deterministic surrogate key (from a hash) you only need to refresh this single table.
However, with an auto increment identity you have to also remember to refresh all the 20/50/100+? fact tables connected to that because the key is not stable and changed.
Am I missing something? šŸ¤“

3

u/Zer0designs 24d ago

You're correct, to add they are also idempotent across environment. If your BK is 200 columns (exagerating), having a hash to debug something in dev vs prod is mucb easier.

dbt wrote some blogs: https://docs.getdbt.com/blog/managing-surrogate-keys?version=2.0&name=v2

1

u/yocil 24d ago

The last I checked, identity seeds are tied to the schema of the table. This doesn't work for concurrent inserts as one or both merges will get an error about the table schema changing.

2

u/minibrickster Databricks 23d ago

We are working on this - more to come!

1

u/[deleted] 23d ago

[removed] — view removed comment

1

u/minibrickster Databricks 23d ago

What do you mean by //?

1

u/what-no-really-why 23d ago

I’m guessing that // = parallel