user15915737
user15915737

Reputation: 320

dbt produce new schema instead of using the already existing

I'm using dbt core and I need to use my models on already existing schema. However when I'm trying to use one already existing It creates new schema, like schema name from profile + config model, in my case: BRONZE_SILVER.

profiles.yml:

dbt_snowflake:
  outputs:
    dev:
      ...
      schema: BRONZE
      ...

  target: dev

Config of my model.sql :

{{
    config(
        alias='DIM_TABLE',
        schema='SILVER',
    )
}}

What should I change in my config ?

Upvotes: 0

Views: 1349

Answers (1)

user15915737
user15915737

Reputation: 320

Actually, I need to create a macro to use custom schema, like explain by the dbt doc.

In macro folder, create macro get_custom_schema.sql :

-- put this in macros/get_custom_schema.sql

{% macro generate_schema_name(custom_schema_name, node) -%}
    {{ generate_schema_name_for_env(custom_schema_name, node) }}
{%- endmacro %}

Upvotes: 3

Related Questions