Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CT-2374] [Bug] global materialization attribute overrides more specific package attributes #7277

Closed
2 tasks done
sfc-gh-afedorov opened this issue Apr 5, 2023 · 3 comments
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core

Comments

@sfc-gh-afedorov
Copy link

sfc-gh-afedorov commented Apr 5, 2023

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

brooklyn-data/dbt_artifacts#284

when I define

models:
  +materialized: view

this overrides a package's more specific

models:
  dbt_artifacts:
    sources:
      +materalized: incremental

which seems like something that violates some general compartmentalization principle

Expected Behavior

more specific attribute definitions should override more general globally defined defaults

Steps To Reproduce

  1. create minimal dbt setup with dbt_artifacts installed
  2. update yaml files as above
  3. invoke dbt run --select dbt_artifacts

Relevant log output

first -

03:13:44  3 of 34 START sql view model afedorov.model_executions ......................... [RUN]

and then -

03:13:50  on-run-end failed, error:
03:13:50   001759 (42601): SQL compilation error:
03:13:50  INSERT statement's target must be a table

Environment

- OS: macos
- Python: 3.9.12
- dbt: 1.4.4

Which database adapter are you using with dbt?

snowflake

Additional Context

image

@sfc-gh-afedorov sfc-gh-afedorov added bug Something isn't working triage labels Apr 5, 2023
@github-actions github-actions bot changed the title [Bug] global materialization attribute overrides more specific package attributes [CT-2374] [Bug] global materialization attribute overrides more specific package attributes Apr 5, 2023
@dbeatty10 dbeatty10 self-assigned this Apr 5, 2023
@jtcohen6
Copy link
Contributor

jtcohen6 commented Apr 5, 2023

It's nestled pretty deeply in the docs, but it is in there:

Configurations made in your dbt_project.yml file will override any configurations in a package (either in the dbt_project.yml file of the package, or in config blocks).

https://docs.getdbt.com/docs/build/packages#configuring-packages

@dbeatty10
Copy link
Contributor

@sfc-gh-afedorov Thanks for opening this !

As @jtcohen6 mentioned, you are observing behavior that we expect, and I'll try to explain why.

Order of precedence

The order of precedence for configs is as follows (highest priority first):

  1. Configuration within your dbt project:
    1. config() Jinja macro within a model
    2. config resource property in a .yml file
    3. dbt_project.yml file, under the models: key -- deepest nested being highest priority
  2. Configuration within an installed package ("second verse, same as the first"):
    1. config() Jinja macro within a model
    2. config resource property in a .yml file
    3. dbt_project.yml file, under the models: key -- deepest nested being highest priority

Reason

One purpose of the dbt_project.yml file is specifically to allow the override of configurations of installed packages. Rather than forcing you to apply these overrides at the lowest level of granularity, it allows you to specify those overrides at the highest level that meets your needs.

Example

You can quickly and easily disable all models from the dbt_artifacts package at a high level of granularity within your dbt_packages.yml like this:

models:
  dbt_artifacts:
    +enabled: false

If the config across your dbt project and all the installed packages were fully flattened, then you would need to apply any overrides at the most granular level possible (model-by-model) in order for the overrides to take effect.

Summary

I'm going to close this as "not planned" since this is the intended behavior rather than a bug.

I've personally ran into this same thing before without realizing it, and I opened the following issue in a separate repo to warn when this situation arises:

Also opened this issue to improve the docs:

@dbeatty10 dbeatty10 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2023
@dbeatty10 dbeatty10 added wontfix Not a bug or out of scope for dbt-core and removed triage labels Apr 5, 2023
@dbeatty10 dbeatty10 removed their assignment Apr 5, 2023
@sfc-gh-afedorov
Copy link
Author

Got it, thanks for the thorough explanation and thinking this through. A warning would have been a good alternative in my case, as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working wontfix Not a bug or out of scope for dbt-core
Projects
None yet
Development

No branches or pull requests

3 participants