0
votes

We started using the seeds functionality in DBT, we put a single CSV file in the data folder, and configured the seed to use a custom schema named util --- and it works (i.e. - it creates a table in the correct schema).

yaml looks like this:

seeds:
  my_project_name:
    +schema: util

However, when we refer to it using ref in our models:

{{ref('my_seed')}}

it looks for it in our default target schema for the environment (public ), instead of the custom one we defined --- how come?

I should mention that we also used the macro trick mentioned here: https://docs.getdbt.com/docs/building-a-dbt-project/building-models/using-custom-schemas

Update: Adding the macro code we used (as the file get_custom_schema.sql):


{% macro generate_schema_name(custom_schema_name, node) -%}
    {{ generate_schema_name_for_env(custom_schema_name, node) }}
{%- endmacro %}
1
To confirm, have you added the generate_schema_name to your project? If so, could you add the macro to the post?dylanbaker
yep, i used the exact macro as given in the example in the dbt docs, i'll add itKlayhamn
also, if it helps, I believe i ran dbt locally using 17.0 and our cloud dbt deployment runs 17.2Klayhamn
After digging a bit in Cloud DBT and the docs, it seems like it's caused by the target name for the job being defined as "default" (which i also believe is the default value for a job?) rather than "prod" --- I have to admit I never quite understood that - and what are we supposed to put there in Cloud DBT... (i.e. - what's the relationship between the "environment" and the "target name" of a job..) docs.getdbt.com/docs/dbt-cloud/using-dbt-cloud/…Klayhamn

1 Answers

0
votes

Not sure the + is needed in front of schema, based on the code example here.

Another option would be to define the schema for the specific seed table:

seeds:
  my_project_name:
    my_seed:
      schema: util