Search code examples
dbt

How to read a variable defined in dbt_project.yml to a dbt .sql model configuration


How can we refer a variable defined in dbt_project.yml to a sql dbt model

vars:
  schema_name: "PUB"

The dbt .sql model code in which i want to refer this variable is in quoted between asterick below:

{{
  config(
      database= 'RND',
      schema= *schema_name*
  )
}}

Solution

  • If you want to specify it one file at a time, you can do the following.

    {{
      config(
          database= 'RND',
          schema= var('schema_name')
      )
    }}