【发布时间】:2020-08-24 09:24:38
【问题描述】:
我们使用 dbt cloud 来运行我们的 dbt 项目。在 CI 运行时,dbt Cloud 使用与 PR 编号相关的模式名称,例如dbt_cloud_pr_5205_543.
有没有办法覆盖这种行为?
更新:我们更新了如下宏。
generate_schema_name.sql
% macro generate_schema_name(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if target.name[-3:] == 'dev' -%}
{{ target.schema }}_{{ custom_schema_name | trim }}
{%- elif target.schema[:9] == 'dbt_cloud' -%}
{{ target.schema }}_{{ custom_schema_name | trim }}
{%- elif custom_schema_name is none -%}
{{ default_schema }}
{%- else -%}
{{ custom_schema_name | trim }}
{%- endif -%}
{%- endmacro %}
【问题讨论】:
-
嗨,Sebastián,您能否详细说明“烧结”类型的模式是什么意思?你指的是dbt项目的
target架构吗? -
docs.getdbt.com/docs/dbt-cloud/using-dbt-cloud/… 我们不再看到 ci 作业中生成的 dbt 模式
-
我们根据 dbvt
generate_schema_name.sql% macro generate_schema_name(custom_schema_name, node) -%} {%- set default_schema = target.schema -%} {%- if target.name[-3:] == 'dev' -%} {{ target.schema }}_{{ custom_schema_name | trim }} {%- elif target.schema[:9] == 'dbt_cloud' -%} {{ target.schema }}_{{ custom_schema_name | trim }} {%- elif custom_schema_name is none -%} {{ default_schema }} {%- else -%} {{ custom_schema_name | trim }} {%- endif -%} {%- endmacro %}将宏更新如下 -
我建议将此宏移至答案并将其作为自答问答帖关闭。看起来像一个有用的宏!
标签: continuous-integration dbt