I have an issue using custom schema names in a dbt package.
I use the Macro provided in dbt documentation.
{% 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 %}
I put this macro in my dbt package here dbt package.
Finally I use this dbt package in another dbt project dbt project.
Here is my dbt_project.yml in my dbt project :
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:
- "target"
- "dbt_modules"
My dbt_project.yml in my dbt package :
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:
- "target"
- "dbt_modules"
models:
covid_france:
stg:
materialized: table
schema: stg
ods:
materialized: table
process-airbyte-outputs:
schema: ods
unions:
schema: ods
prs:
materialized: view
When I try to run my dbt project, it imports the dbt package but doesn't apply the macro that is supposed to remove the main schema prefix (provided in profiles.yml) from custom schema names
For instance : the schema provided in my profiles.yml is "prs". I have other custom schemas named ods and stg. But when dbt run, it create prs, prs_ods and prs_stg.
The macro used to work fine when I use it directly in a dbt project (instead of putting it in a dbt package that I use in my dbt project)
Thank you in advance !
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…