Skip to content

Set configs in schema.yml files #2401

@drewbanin

Description

@drewbanin

Describe the feature

Let's bring the schema.yml spec and node configs together! Right now, some configs can only be set for a node in the node's .sql file with config() or in the dbt_project.yml file. These configs include:

  • materialized
  • enabled
  • tags
  • database-specific configs (bind, sort, dist, etc)
  • etc

These configs can not be configured in the schema.yml file. At the same time, there are some configs that can only be set in a schema.yml file:

  • description
  • columns (tags, descriptions, tests, etc)
  • tags (for sources)

Instead, it would be ideal if these configs could be supplied in either place, with a sensible and well-defined precedence rules.

Example usage:

-- models/my_model.sql
/*
  Configure the description and columns for a model inline in a config.
  Note: I'd probably advise against doing this, but it should be possible
*/

{{ config(
  description="This is my model description",
  columns=[
    [
      {"name": "id", "description": "The primary key"}
    ]
) }}

select ...
# models/schema.yml
version: 2
models:
 - name: my_model
   config:
      tags: ["nightly"]
      materialized: view

Some configs, like tags or freshness in a source are set at the root level of the source. Today, this looks like:

version: 2
sources:
 - name: my_source
   tags: [my_tag]

We should continue to support this syntax, but it would also be good to allow a config level key which scopes these configurations, eg:

version: 2
sources:
 - name: my_source
   config:
      tags: [my_tag]

We should not allow these configs to be configured at both the root-level and the config level for parsing simplicity.

Additional context

I fear that this might be a really big departure from how parsing works today. Some fields, like description are patched into model objects. Would this feature require us to drastically change how we parse nodes in dbt?

Metadata

Metadata

Assignees

Labels

1.0.0Issues related to the 1.0.0 release of dbtdiscussionenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions