-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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-2465] [Bug] meta
field inheritance in sources works exactly the wrong way
#7440
Comments
meta
field inheritance in sources works exactly the wrong waymeta
field inheritance in sources works exactly the wrong way
Hi @Maayan-s 😁 Something to tryWhat do the priorities look like if you try the following instead? In the sources:
# for sources, it appears okay to put config up here, but I don't think it's okay for models
# +meta:
# debug: "top_level_config"
your_dbt_project_name:
+meta:
debug: "project_level_config" And for a specific source: sources:
- name: source_name
schema: source_schema
config:
meta:
debug: "source_level_config"
tables:
- name: table_name
config:
meta:
debug: "table_level_config" In {% set sources = [] -%}
{% for node in graph.sources.values() -%}
{{ tojson(node) }}
{%- endfor %} Compile and pretty-print the JSON for the source nodes: dbt compile
jq . target/compiled/your_dbt_project_name/analyses/my_analysis.sql > source_nodes.json Maximum detailTo really see in detail how everything is affecting the In the sources:
+meta:
debug: "top_level"
config:
+meta:
debug: "top_level_config"
my_dbt_project:
+meta:
debug: "project_level"
config:
+meta:
debug: "project_level_config" And for a specific source: sources:
- name: source_name
schema: source_schema
meta:
debug: "source_level"
config:
meta:
debug: "source_level_config"
tables:
- name: table_name
meta:
debug: "table_level"
config:
meta:
debug: "table_level_config" Here's a subset of the JSON key/values: {
"database": "postgres",
"schema": "dbt_dbeatty",
"name": "sample_model",
"resource_type": "source",
"package_name": "my_dbt_project",
"path": "models/_sources.yml",
"original_file_path": "models/_sources.yml",
"unique_id": "source.my_dbt_project.dbt_dbeatty.sample_model",
"fqn": [
"my_dbt_project",
"dbt_dbeatty",
"sample_model"
],
"source_name": "dbt_dbeatty",
"identifier": "sample_model",
"meta": {
"debug": "table_level"
},
"source_meta": {
"debug": "source_level"
},
"config": {
"enabled": true,
"meta": {
"debug": "table_level_config"
}
},
"unrendered_config": {
"meta": {
"debug": "table_level_config"
}
},
"relation_name": "\"postgres\".\"dbt_dbeatty\".\"sample_model\"",
} This looks like the priorities you expecting, but let me know either way! |
Hi @dbeatty10,
Whereas without The thing is this is really inconsistent (and undocumented). |
😅 This feedback is fair, @Maayan-s InconsistenciesI don't know for certain, but some or all of the inconsistency for sources might be covered by #3662 DocumentationAt the very least, would some clear documentation within the docs for
Of course we'd also want to update all the examples within the |
I agree this is quite inconsistent & confusing. The current complexity is there for two reasons:
https://docs.getdbt.com/reference/resource-configs/meta#definition
I would like to develop a general-purpose answer to the inconsistencies that exist today between "configurations" (which can be inherited & overridden) and "properties" (which cannot): |
Thanks @jtcohen6 and @dbeatty10! Changing the docs is for sure the immediate solution, and I understand the planned solution and think it's solid and will solve a lot of confusion! |
If I should break this off into a separate bug or feature request issue please let me know. In dbt-labs/docs.getdbt.com#3710, which came from this issue, @dbeatty10 says The following in a models:
meta:
owner: "@Richard"
dbt_builder: "@Alison"
- name: model_name_A
- name: model_name_B The error is:
but the following is fine: models:
- name: model_name_A
meta:
owner: "@Richard"
dbt_builder: "@Alison"
- name: model_name_B
meta:
owner: "@Richard"
dbt_builder: "@Alison" I should(want to be able to) specify meta data for an entire set of models without having to put the same meta data under each model in a model set. In that way, I can keep my code DRYer. I also tried the following 2 versions and got the same models:
config:
meta:
owner: "@Richard"
dbt_builder: "@Alison"
- name: model_name_A
config:
meta:
owner: "@Richard Model"
dbt_builder: "@Alison Model" models:
config:
+meta:
owner: "@Richard"
dbt_builder: "@Alison"
- name: model_name_A
config:
+meta:
owner: "@Richard Model"
dbt_builder: "@Alison Model" |
@alison985 I think this is a just a misunderstanding due to me using the phrase "top-level" too loosely in combination with Inside of
ExampleSuppose you put all your Richard/Alison models into a folder named name: "my_project"
profile: "my_profile"
models:
my_project:
+meta:
owner: "@Default_Owner_Across_This_Project"
dbt_builder: "@Default_dbt_Builder_Across_This_Project"
# relative path: models/ra
ra:
+meta:
owner: "@Richard"
dbt_builder: "@Alison" ExplanationIn this example, all models within Otherwise, they will have the |
This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days. |
Although we are closing this issue as stale, it's not gone forever. Issues can be reopened if there is renewed community interest. Just add a comment to notify the maintainers. |
Is this a new bug in dbt-core?
Current Behavior
Hi team 😁
According to the docs here:
"meta dictionaries are merged (a more specific key-value pair replaces a less specific value with the same key)"
This indeed happens for models and tests.
However in sources the less specific value is replaces the more specific one.
I played with configuring
meta
in different levels, and the priorities are:Expected Behavior
Priorities should be:
3. dbt_project.yml meta
2. source level meta
(exactly the other way around from current behavior)
Steps To Reproduce
I'm using dbt latest release (1.4.6).
In the
dbt_project.yml
I configured:And for a specific source I configured:
When I extract the meta field from the graph, I get the
project_level
value under debug.When I remove the config from
dbt_project.yml
and extract the meta field from the graph, I get thesource_level
value under debug.When I remove the config from the source and extract the meta field from the graph, I get the
table_level
value under debug.Relevant log output
No response
Environment
Which database adapter are you using with dbt?
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: