on-run-end

⚠️
 

Heads up!

This is a work in progress document.
dbt_project.yml
on-run-end: sql-statement

Definition

A SQL statement (or list of SQL statements) to be run at the end of the following commands:

  • dbt run
  • dbt seed

on-run-end hooks can also call macros that return SQL statements.

Examples

Grant privileges at the end of a run

dbt_project.yml
on-run-end: "grant select on all tables in schema {{ target.schema }} group transformer"

Grant multiple privileges at the end of a run

dbt_project.yml
on-run-end:
- "grant usage on schema {{ target.schema }} to group reporter"
- "grant select on all tables in schema {{ target.schema }} group reporter"

Grant privileges on all schemas that dbt uses at the end of a run

This leverages the schemas variable.

dbt_project.yml
on-run-end:
- "{% for schema in schemas %}grant usage on schema {{ schema }} to group reporter; {% endfor %}"

Call a macro to grant privileges

dbt_project.yml
on-run-end: "{{ grant_select(schemas) }}"