我在 dbt 包中使用自定义架构名称时遇到问题。
我使用dbt 文档中提供的宏。
{% macro generate_schema_name(custom_schema_name, node) -%}
{%- set default_schema = target.schema -%}
{%- if custom_schema_name is none -%}
{{ default_schema }}
{%- else -%}
{{ default_schema }}_{{ custom_schema_name | trim }}
{%- endif -%}
{%- endmacro %}
Run Code Online (Sandbox Code Playgroud)
我把这个宏放在我的 dbt 包中dbt package。
最后我在另一个dbt项目dbt项目中使用这个dbt包。
这是我的 dbt 项目中的 dbt_project.yml :
name: 'covid_france'
version: '0.0.1'
config-version: 2
profile: 'default'
source-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
target-path: "target"
clean-targets:
- …Run Code Online (Sandbox Code Playgroud) dbt ×1