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

Triggering Downstream Workflow in Databricks from New Inserts in Snowflake

abelian-grape
New Contributor III

Hi Databricks experts,

I have a table in Snowflake that tracks newly added items, and a downstream data processing workflow that needs to be triggered whenever new items are added. I'm currently using Lakehouse Federation to query the Snowflake tables in Databricks.

How can I set up a mechanism to trigger the downstream data processing step with the newly added items? For example, if table X in Snowflake receives a new insert with item_id = 84848, the workflow should be triggered to run analysis based on this item_id. The trigger can be either interval-based or event-driven.

What would be the best approach to implement this in databricks?

2 REPLIES 2

Brahmareddy
Honored Contributor III

Hi abelian-grape,

Great question! Since you're using Lakehouse Federation to access the Snowflake table, and Databricks can't directly stream from or listen to inserts in Snowflake, the best approach is to use an interval-based polling mechanism in Databricks. You can set up a scheduled Databricks Job (or a simple notebook) that runs every few minutes, queries the Snowflake table via Lakehouse Federation, and checks for any new item_ids based on a timestamp or an incrementing ID column. If new items are found, you can trigger your downstream workflowโ€”for example, by chaining tasks in a Databricks Workflow or using a REST API call to another job. To avoid reprocessing the same items, store the last processed timestamp or item_id in a Delta table or a control table. While itโ€™s not true event-driven processing, this pattern is reliable and works well with external sources like Snowflake. Let me know if you want help setting up the polling logic or job scheduling!

Regards,

Brahma

Hey @Brahmareddy, I ended up creating a Delta table as a mirror of the source Snowflake table (accessed via Lakehouse Federation). I set up logic to append only new records to the Delta table based on a timestamp columnโ€”so only records where the timestamp is greater than the current max get added

Then I use readStream in append mode to write those new records to a staging Delta table. The downstream process picks up from this staging tableโ€”so for example, it processes new items like 3, 4, 5โ€”and then I delete the processed records from the staging table to ensure only new data gets handled incrementally.

What do you think of this approach? Am I overcomplicating it?

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local communityโ€”sign up today to get started!

Sign Up Now