dbt

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?


Solution

  • 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: https://docs.getdbt.com/reference/resource-configs/enabled