You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将原有DBT权限配置转换为DBT Grants功能等价配置?

等价的dbt Grants功能实现方案

1. 角色创建逻辑保留

角色创建不属于dbt grants的核心权限管理范畴,继续在dbt_project.yml中保留原有配置:

on-run-start:
  - "{{ create_role__create_procedure('Role1') }}"
  - "{{ create_role__create_procedure('Role2') }}"

2. 替换Schema SELECT权限配置

dbt grants会自动在模型部署后同步权限,替代原on-run-end中的grant_select_on_schemas调用,有两种配置方式:

全局项目配置(全项目模型生效)

在dbt_project.yml中添加:

models:
  [你的项目名]:
    +grants:
      select: ['Role1']
    +schema: Schema1  # 若项目模型默认部署到Schema1,可指定该全局schema

单个模型配置(仅目标模型生效)

在需要授权的模型SQL文件头部添加配置:

{{ config(
    schema='Schema1',
    grants={
        'select': ['Role1']
    }
) }}

-- 模型SQL代码

3. 角色层级授权

dbt grants暂不支持角色间的授权操作,继续在on-run-end中保留原生SQL:

on-run-end:
  - GRANT ROLE Role1 TO ROLE Role2;

内容的提问来源于stack exchange,提问作者sree

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 15:45:47