cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use change data feed when schema is changing between delta table versions?

LasseL
New Contributor

How to use change data feed when delta table schema changes between delta table versions?

I tried to read change data feed in parts (in code snippet I read version 1372, because 1371 and 1373 schema versions are different), but getting error

UnsupportedOperationException: [DELTA_CHANGE_DATA_FEED_INCOMPATIBLE_DATA_SCHEMA] Retrieving table changes between version 1372 and 1372 failed because of an incompatible data schema.

Your read schema is {"type":"struct","fields":[{"name":..."metadata":{}}]} at version 1375, but we found an incompatible data schema at version 1372.

Code snippet:

df_test = (
    spark.read.format('delta')
    .option("readChangeFeed", "true")
    .option("startingVersion", 1372)
    .option("endingVersion", 1372)
    .load(path)
)
 
df_test.display()
 
So does that mean that change data feed is using the last (or the first) feeding version schema? Can this be changed? Streaming is not option (in streaming you can add schema change tracking).
Is there any trick to get this working?
1 REPLY 1

raphaelblg
Contributor III
Contributor III

Hi @LasseL, Please check: What is the schema for the change data feed? . It might help you

 

Best regards,

Raphael Balogo
Sr. Technical Solutions Engineer
Databricks
Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!