Search code examples
pythondbt

Exclude a file while importing a dbt package


I've an internal dbt project and want to import it into another project as a package. While doing so.. I also want to exclude a particular file.

The internal project is there in a git repository and after adding a line in packages.yml like this - - git: "https://github.com/abc/dbt_test.git" revision: "master"

I do see it under dbt_packages folder. How do I exclude some files here?

I tried using like this - ` - git: "https://github.com/abc/dbt_test.git" revision: "master" exclude: "models/folder1/folder2/data_model.sql

` It shows the following error - Validator Error:

{'git': 'https://github.com/abc/dbt_test.git', 'revision': 'main', 'exclusions': ['"models/folder1/folder2/data_model.sql']} is not valid under any of the given schemas

Solution

  • You can disable a model from a package in your dbt_project.yml. For instance, if the model you want to disable is in the models/ directory, you would do the following:

    models:
      <your_package>:
        <model_you_want_to_disable>:
          +enabled: false
    

    You will need to address the directory structure of the project you are using as package when disabling models.

    E.g. if the model you want to disable is in models/staging/hubspot, your dbt_project.yml should look like this:

    models:
      <your_package>:
        staging:
          hubspot:
            <model_you_want_to_disable>:
              +enabled: false