You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Presently, in-model hook definitions need to be set in a {{ config() }} block. This isn't the most natural place for long-form SQL. Instead, dbt should provide a set of helper macros for setting pre- and post- hooks. For example:
{{ config(materialized='table') }}
{{ post_hook("grant select on {{ this }}" to db_reader") }}
{{ post_hook(some_complex_macro()} }}
This will also be a nice interface for inclusion in higher-level macros.
Who will this benefit?
Users with many model-specific hooks.
The text was updated successfully, but these errors were encountered:
IMHO, variables would probably handle this more easily and without work from you:
{% set post_hook %}
{% for role in ['db_reader', 'db_writer'] %}
grantselecton {{ this }} to {{ role }};
{% endfor %}
{% endset %}
{{ config({ 'materialized': 'table', 'post-hook': post_hook}) }}
Probably deserves an update to your documentation though, since folks may not know about multi-line set blocks.
Feature
Feature description
See also #558
Presently, in-model hook definitions need to be set in a
{{ config() }}
block. This isn't the most natural place for long-form SQL. Instead, dbt should provide a set of helper macros for setting pre- and post- hooks. For example:This will also be a nice interface for inclusion in higher-level macros.
Who will this benefit?
Users with many model-specific hooks.
The text was updated successfully, but these errors were encountered: