[v2 Bug] graph.groups entries use the internal node layout, so group.name and group.owner are undefined
Is this a new bug in dbt v2.x compared to the latest version of dbt 1.x?
- I believe this is a new bug in dbt v2.x
- I have searched the existing issues and could not find a duplicate
Current Behavior
Since #14209, graph.groups is populated. But each entry is the serialized internal DbtGroup struct, with fields under __common_attr__, __base_attr__ and __group_attr__. So group.name and group.owner are undefined. graph.nodes, graph.sources, graph.exposures and graph.metrics are flattened as in dbt 1.x.
Expected Behavior
graph.groups entries have the same shape as in dbt 1.x and manifest.json, with top-level name, owner, unique_id and so on. That's also what the graph docs describe.
Steps To Reproduce
# models/schema.yml
groups:
- name: finance
owner:
name: Finance Team
email: [email protected]
models:
- name: my_model
config:
group: finance-- models/my_model.sql
select 1 as id-- macros/print_groups.sql
{% macro print_groups() %}
{% for group in graph.groups.values() %}
{% do print(tojson(group)) %}
{% do print("name=" ~ group.name ~ " owner=" ~ group.owner) %}
{% endfor %}
{% endmacro %}dbt run-operation print_groupsRelevant log output
dbt 2.0.6 (trimmed):
{"__base_attr__": {"adapter": "duckdb", "alias": "", "columns": {}, ...}, "__common_attr__": {"name": "finance", "unique_id": "group.probe.finance", "path": "models/schema.yml", ...}, "__group_attr__": {"owner": {"email": "[email protected]", "name": "Finance Team"}}}
name= owner=dbt-core 1.10.23:
{"name": "finance", "resource_type": "group", "package_name": "probe", "path": "schema.yml", "original_file_path": "models/schema.yml", "unique_id": "group.probe.finance", "owner": {"email": "[email protected]", "name": "Finance Team"}, "description": null, "config": {"meta": {}}}
name=finance owner={'email': '[email protected]', 'name': 'Finance Team'}Environment
- OS: Linux (Ubuntu 22.04)
- CPU: x86
- dbt distribution and version: dbt 2.0.6 (Fusion)
Which database adapter are you using?
duckdb, snowflake (it doesn't depend on the adapter)
Is this a discrepancy vs. dbt 1.x?
- Yes — this works in dbt 1.x but not in dbt v2.x
Additional Context
In build_flat_graph, groups are the only collection serialized straight from the struct:
.map(|(unique_id, group)| (unique_id.clone(), Value::from_serialize(Arc::as_ref(group))))Metrics, semantic models and saved queries go through InternalDbtNode::serialize() instead. DbtGroup doesn't implement InternalDbtNode. Serializing ManifestGroup::from(...) (what manifest.json uses) would probably fix it.
We hit this in the Elementary dbt package. It reads graph.groups to upload groups and to derive model owners from the group owner. On Fusion, both come back empty.
Source: dbt-labs/dbt-core