Triggers
Overview
Triggers are a special type of materialization that let you react to events in your data. When you define a Trigger you provide a SQL select statement and, a python function or Jinja macro to be executed when your trigger fires. When a Trigger is materialized, your select statement is used to define a view. Whenever any rows fall into that view, your function/macro will be called.
Triggers are the primary mechanism for building event based pipelines in Balto. You can even use Triggers with the Balto orchestration metadata views to create complex cross-project workflows.
Usage
Syntax
To create a trigger add a new sql model with a materialization type of trigger
and handler
set to the FQN of the stored procedure that will be called when your trigger fires.
1 2 3 4 5 6 7 8 9 10 11 |
|
Handlers must accept a single string argument, which is a reference to the stream which holds any new rows for your handler to process. The stream can be referenced as follows:
1 2 3 4 5 6 7 8 9 10 11 |
|
Limitations
Triggers are implemented in Snowflake using a stream on top of a view created from your Trigger's select clause. This means that the same general limitations for streams on views in Snowflake apply to your Trigger.
Examples
Push application event metrics
The following example creates a Trigger which will push a DataDog metric with the count of large payments tagged by payment_method
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|