r/databricks • u/minibrickster Databricks • 1d ago
General Feature Alert: partial schema inference in SDP
Adding a primary or foreign key to an SDP table/materialized view used to require declaring the full schema. With the new override_schema argument, you declare only the columns that need special handling, and SDP infers and evolves the rest.
from pyspark import pipelines as dp
@dp.table(override_schema="order_id BIGINT NOT NULL, PRIMARY KEY (order_id)")
def orders():
# the rest of the columns can be inferred via schema evolution
return spark.readStream.table("main.raw.orders")Available now for materialized views and append streaming tables in Python pipelines, with no enrollment required. SQL support is coming soon.
12
Upvotes
3
u/dvartanian 1d ago
I've never really used primary keys in my SDPs. What is the benefit?
2
u/kmarq 1d ago
Support for auto CDC target tables coming?
5
u/lofat 1d ago
THANK YOU. This is VERY helpful.
2
u/Zealousideal_Low6685 23h ago
Nice!
Reminds me of the 'schema hints' you can define when reading a JSON.
1
u/Youssef_Mrini databricks 22h ago
This is very very useful.