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 II

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
Databricks Employee
Databricks Employee

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

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group