Configure SQL before model execution with sql headers
SQL headers allow you to manipulate the current session settings, such as roles and timezones, directly within your asset's run session.
You can define SQL headers directly in the SQL file's config block, within YAML configs, or in the dbt_project.yml
Example in a Snowflake SQL asset:
Example in dbt_project.yml:
Using set_sql_header
The set_sql_header
macro offers a convenient way to inject multi-line SQL statements without using the sql_header
configuration key. It simplifies the inclusion of complex session manipulations directly within your asset definitions.