user3735871
user3735871

Reputation: 317

Why dbt doesn't use the schema defined

I have configured dbt_project.yml as

var:
   schema: "my_schema"
models:
   my_models:
      landing:
         +schema: schema_not_local 

and profile.yml as

dbt_myproject:
  outputs: 
     local:
        schema: "my_schema"

When I run dbt run --target local --vars '{"schema" : "my_schema"}', for all models under dbt_myproject, dbt still tried to create a schema saying "creating schema if nit exists my_db." , and failed with error as it doesn't have a schema after the database name. For debug logs it seems that in the sql, schema is recognised as my_schema and db as the one in the target defined in profile.yml. Why does dbt still try to create schema instead of using "my_schema"?

Upvotes: 0

Views: 86

Answers (1)

samhita
samhita

Reputation: 3505

schema_not_local might be overriding the var.

Try below

dbt_project.yml

var:
  schema: "my_schema"  

models:
  my_models:
    landing:
      +schema: "{{ var('schema') }}"  

Profiles.yml

dbt_myproject:
  outputs:
    local:
      type: snowflake  
      account: your_account
      user: your_user
      password: your_password
      database: my_database
      schema: "{{ var('schema') }}" 

Upvotes: 0

Related Questions