dbt found two schema.yml entries for the same resource

The problem I’m having

I have 2 yml, 1 where y have the incremental configuration for my models and other where i want to add the descriptions and docs, but it seems i cant.

The context of why I’m trying to do this

In my model i have a lot of columns i want to have some sort of description and possible add blocks in the future, and i want to separte that from the incremental configuration im trying, but i allways run in to the same problem:

“dbt found two schema.yml entries for the same resource named s_customer. Resources and their associated columns may only be described a single time.”

Some example code

models/conf.yml

  - name: s_customer
    config:
      materialized: incremental
      unique_key : [h_customer_haskey,load_record]
      incremental_strategy: merge
      merge_exclude_columns: [h_customer_haskey,custkey]
    columns:
      - name: h_customer_haskey
        tests:
          - relationships:
              field: h_customer_haskey
              to: ref('h_customer')

models/cutomer/schema.yml

models:
  - name: s_customer
    description: "description"
    columns:
      - name: h_customer_haskey
        description: "description"
      - name: has_diff
        description: "description"
      - name: load_record
        description: "description"
      - name: is_active
       description: "description"
      - name: last_modified
        description: "description"
      - name: source
        description: "description"
      - name: custkey
        description: "description"
      - name: addres
        description: "description"
      - name: comment
        description: "description"
      - name: mktsegment
        description: ""
      - name: name
        description: "descriptionr"
      - name: phone
        description: "description"
      - name: accbal
        description: ""

How could i solve my problem? I would like to avoid having all in the same file, becouse i have more models and they can have a lot of columns and is gona be horrible to look at the yml later on.

Sorry ahead of time, english aint my first lenguage.

Hi create the model’s with two different names and use alias.

in your case

models/s_customer_1.sql
models/conf.yml ( replace s_customer with s_customer_1)
inside s_customer_1.sql use
{{ config(materialized=‘table’,alias=‘s_customer’) }}

models/cutomer/s_customer_2.sql
models/cutomer/schema.yml ( replace s_customer with s_customer_1)

inside s_customer_2.sql use
{{ config(materialized=‘table’,alias=‘s_customer’) }}

Hope it should work for your scenerio

I tried and it works but is not what i was looking for, i dont want to have to create the models 2 times if possible in the project, i already have a lot and is gonna be really complicated to navigate throught the project if i do that even if i separate then in another folder. ¿Is there any other way?

Hi, If you are looking to define all descriptions at one place for the columns which are common in multiple tables, I have not seen any feature in dbt to help you. @joellabes - Any help you can provide on this?

Thanks for your time, is a pity i cant do that.

Hello @guserrl .
I think schema alias + below example can help you.

schema file :customer.yml

version: 2

models:

  • name: section for columns comments for customer table
    columns: &section_cols # block of columns which are defined once in schema.yml file
    • name: customer_id
      description: customer unique id
    • name: customer_name
      description: customer name
    • name: customer_age
      description: customer age
    • name: customer_post_code
      description: customer post code

models:

  • name: stg_customer # table one
    description: staging customer table
    columns: *section_cols # referring columns comment block

  • name: customer # table two
    description: primary customer table
    columns: *section_cols # referring columns comment block

stg_customer.sql # model one
{{
config(materialized=‘table’)
}}

select

1 as customer_id,
“naveed” as customer_name,
“s1 e001” as customer_post_code

customer.sql # model two
{{
config(materialized=‘table’)
}}

select

*,
23 as customer_age
from {{ref(“stg_customer”)}}

when i run the both the model’s (in big query) . i can see the descriptions are reflected for both stg_customer and customer table