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:ย 

APPLY AS DELETE without operation

smit_tw
New Contributor III

We are performing a full load of API data into the Bronze table (append only), and then using the APPLY CHANGES INTO query to move data from Bronze to Silver using Stream to get only new records. How can we also utilize the APPLY AS DELETE functionality with a condition to mark records as deleted when their corresponding ID no longer exists in the New Bronze Streaming data?

For example:

  • On Day 1, the Bronze table contains IDs: 1 to 5, and the Silver table will have IDs: 1 to 5.
  • On Day 2, the Bronze table contains IDs: 1 to 4 and 6.
    • In this case, the Silver table should add ID 6, and mark ID 5 as deleted (using the __END_AT field).

How can we achieve this behavior using APPLY CHANGES INTO in Databricks?

2 REPLIES 2

szymon_dybczak
Esteemed Contributor III

smit_tw
New Contributor III

@szymon_dybczak is it possible to do directly in Silver layer? We do not have option to go fo Gold layer. I tried to create a TEMP VIEW in Silver DLT pipeline but it gives error for circular dependency as I am comparing data from Silver it self and also creating it in same script. 

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