{{ schema }} not returning custom schema

I can confirm that compile is wrong and needs flagging as a bug, whereas dbt build and dbt run both work ok using {{ this.schema }}

One last bump - the bug is actually worse because preview also resolves to the wrong schema, so I can’t preview via correct/non-hardocded syntax.

Who do we raise bugs with?

I’d open an issue against dbt core if this is misbehaving in certain contexts only: Issues · dbt-labs/dbt-core · GitHub

I was right - now that the dbt Cloud IDE doesn’t use the deprecated dbt-rpc library, it’s able to compile with the actual state of the model and the issue is resolved.

Note that there is differing behaviour when you compile an unsaved model compared to a saved file:

1 Like

Hi @joellabes

Still getting funny issues with this…

When running/building - {{schema}}, {{this.schema}}, {{model['schema']}} correctly points to gold, {{target.schema}} points to silver
When previewing / compiling - all variations of {{schema}} syntax incorrectly point to silver

gold is the folder this model sits in, and the folder is configured to point to a db schema of the same name.
silver happens to be another folder, which this model isn’t in nor configured to point to in any way.

All tests were run against a saved file.

Current relevant project_yml:

models:
  catalyst_model:
    archive:
      +enabled: false
    gold:
      +schema: gold
      +materialized: table
      +post-hook:
        - "{{ set_object_ownership(this) }}"
    staging:
      +schema: dbt_staging
      +materialized: table
      +post-hook:
        - "{{ set_object_ownership(this) }}"
    reporting:
      +schema: reporting
      +materialized: table
      +post-hook:
        - "{{ set_object_ownership(this) }}"
    silver:
      +schema: silver
      +materialized: table
      +post-hook:
        - "{{ set_object_ownership(this) }}"

I think the issue might be that the last schema in project.yml is used - since prior to the addition of silver, we were pointed to dbt_staging which at the time was the final configured schema - see original project_yml earlier in thread. However, I tried swapping the order of things in project_yml and it didn’t change anything.