我想知道是否可以将post挂钩附加到DBT_CLOUD_PR模式(由DBT_CLOUD_PR生成),以便只有开发人员才能看到数据库上生成的PR表。
我想做如下几件事:
dbt_cloud_pr:
+post-hook:
- "revoke select on {{ this }} from role reporter"现在,我们的dbt_cloud_pr模式可以通过雪花上的多个角色看到,并且它用一些我们更愿意隐藏的非必要模式对数据库进行集群。
谢谢你的帮助!
发布于 2022-04-06 17:43:18
这是个很酷的主意!
您可以将dbt作业配置为使用自定义的“目标”名称(这是作业>编辑设置页面)。假设你把它设置为ci
那么,我认为在您的代码中您应该能够添加一个后置钩子,如
models:
+post-hook: {% if target.name == 'ci' %} revoke select on {{ this }} from role reporter {% else %} select 1 {% endif %}如果在后置钩子本身中不允许使用if..else语法,则可以将其包装在宏中,并从后置钩子调用该宏:
models:
+post-hook: {{ revoke_select_on_ci(this) }}在宏目录中:
{%- macro revoke_select_on_ci(model, ci_target='ci') -%}
{%- if target.name == ci_target -%}
revoke select on {{ model }} from role reporter
{%- else -%}
select 1
{%- endif -%}
{%- endmacro -%}https://stackoverflow.com/questions/71770054
复制相似问题