Disable Dbt Models Using Code or Config (Not Commands)

Disable Dbt Models Using Code or Config (Not Commands)

Hello I have the following DBT project directory structure:

my_dbt_project/
  dbt_project.yml
  profiles.yml
  pyproject.toml
  requirements.txt
  <other config files here>
  models/
    abc/
      abc.yml
      abc.sql
    def/
      def.yml
      def.sql
    ghi/
      ghi.yml
      ghi.sql
    etc.

When I run dbt <cmd> --profiles-dir=. --select models/ where <cmd> is either compile, run or test, DBT runs the command on everything under models/.

In reality I have hundreds of "model subfolders" under models/ and I am trying to disable just one of them (say, def/) so that if I were to run, say, dbt run --profiles-dir=. --select models/, it would run all the model transforms except everything defined under models/def/*.

Because of factors outside the scope of this question, changing the DBT commands is not an option for me. I need a way to configure something in a project file or under the def/ directory (something in the code/configs) to tell DBT to skip over everything under def/ and completely ignore/disable it.

Based on what I've presented above, how can I disable DBT for this specific model?

1 Answer

You can use the enabled flag to disable models. In your example, you can add this to dbt_project.yml to disable all models in def folder:

models:
  def:
    +enabled: false

More details in the documentation:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.