我们使用 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 %}