dbt-labs / dbt-labs/docs.getdbt.com

[Core] Disabling a model in a package in order to use your own version of the model

Open
#5,094 0 comments 0 reactions 0 assignees View on GitHub
content dbt Core size: medium
Dominant language
JavaScript
Stars
215
Forks
1.2k
Avg merge
1d 15h
Merged PRs (30d)
130

Description

### Link to the page(s) on docs.getdbt.com requiring updates

https://docs.getdbt.com/reference/resource-configs/enabled#disable-a-model-in-a-package-in-order-to-use-your-own-version-of-the-model

### Tell us more about this update

It would be helpful if we add the content from https://github.com/dbt-labs/dbt-core/issues/9762#issuecomment-1997744765 as an additional option for folks to consider.

### Reviewers/Stakeholders/SMEs

Doug E. Fresh 😎

### Related GitHub issues

https://github.com/dbt-labs/dbt-core/issues/9762

### Additional information

After installing a package that includes models, the user may want to change the logic of one (or more) of the models.

We explain how [here](https://docs.getdbt.com/reference/resource-configs/enabled#disable-a-model-in-a-package-in-order-to-use-your-own-version-of-the-model).

But it sounds like configuration in YAML files (like tests) still persist from the base package, which is undesireable for some users (see https://github.com/dbt-labs/dbt-core/issues/9762 and [this slack thread](https://getdbt.slack.com/archives/CBSQTAPLG/p1687971743120099)).

The instructions in https://github.com/dbt-labs/dbt-core/issues/9762#issuecomment-1997744765 serve as an alternative method to completely disable the package model, including its YAML configurations.

> 1. Disable the model from the package that you don't want
> 1. Create your own version of the model with a different / unique name
> - i.e., if the package model is named `segment_web_page_views.sql`, then name your version `overridden_segment_web_page_views.sql`
> 1. Optional: set a [custom alias](https://docs.getdbt.com/docs/build/custom-aliases) to the original name
> - so that the materialized database table has the same name as model from the package
> ```yaml
> # models/_models.yml
>
> models:
> - name: overridden_segment_web_page_views
> config:
> alias: segment_web_page_views
> ```

### Another idea

I tried it out the following idea and it did **not** work -- it gives this error:
```
Compilation Error
dbt found two schema.yml entries for the same resource named segment_web_page_views.
```

It doesn't work because dbt sees the package's `_models.yml` and the root project's `_models.yml` as duplicate entries for the same resource, even though the package model is disabled. See https://github.com/dbt-labs/docs.getdbt.com/issues/8724 for more info.

`dbt_project.yml`

```yaml
models:
segment:
base:
segment_web_page_views:
+enabled: false
```

`models/_models.yml`

```yaml
models:
- name: segment_web_page_views
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.