Skip to content

feat: add config.tags and +tags support for metrics#12604

Open
dtaniwaki wants to merge 1 commit intodbt-labs:mainfrom
dtaniwaki:fix/metric-project-config-tags
Open

feat: add config.tags and +tags support for metrics#12604
dtaniwaki wants to merge 1 commit intodbt-labs:mainfrom
dtaniwaki:fix/metric-project-config-tags

Conversation

@dtaniwaki
Copy link

@dtaniwaki dtaniwaki commented Mar 6, 2026

Resolves #12607

Thanks for maintaining dbt-core! I'd appreciate your review on this PR.

Problem

Metrics do not support config.tags in YAML or +tags in dbt_project.yml. There is no way to apply tags to metrics through the standard config system, making it inconsistent with other resource types.

Additionally, v1 metrics had a top-level tags: field that was silently applied to the node outside of the config system, which is inconsistent with how other resource types handle tags.

Solution

Add tags to MetricConfig using MergeBehavior.Append, so tags from dbt_project.yml (+tags) and from config.tags in YAML are merged, deduplicated, and sorted.

YAML config block:

metrics:
  - name: my_metric
    ...
    config:
      tags:
        - finance

dbt_project.yml:

metrics:
  my_project:
    +tags:
      - finance

Top-level tags: on v1 metrics (outside of a config: block) now emit a ValidationWarning directing users to use config.tags instead, since metrics implement tags via the config system only.

A normalize_tags() helper is introduced in parser/common.py to deduplicate and sort tags consistently, and is reused across ExposureParser, MetricParser, and SavedQueryParser.

Checklist

  • I have read the contributing guide and understand what's expected of me.
  • I have run this code in development, and it appears to resolve the stated issue.
  • This PR includes tests, or tests are not required or relevant for this PR.
  • This PR has no interface changes (e.g., macros, CLI, logs, JSON artifacts, config files, adapter interface, etc.) or this PR has already received feedback and approval from Product or DX.
  • This PR includes type annotations for new and modified functions.

@dtaniwaki dtaniwaki requested a review from a team as a code owner March 6, 2026 06:18
@cla-bot cla-bot bot added the cla:yes label Mar 6, 2026
@github-actions github-actions bot added the community This PR is from a community member label Mar 6, 2026
@dtaniwaki dtaniwaki force-pushed the fix/metric-project-config-tags branch from 33a7066 to e515af0 Compare March 6, 2026 06:20
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@dtaniwaki dtaniwaki force-pushed the fix/metric-project-config-tags branch from 518c38d to 38b37eb Compare March 6, 2026 12:25
@dtaniwaki dtaniwaki changed the title feat: add tags support to semantic models fix: apply +tags from dbt_project.yml to metrics Mar 6, 2026
@dtaniwaki dtaniwaki force-pushed the fix/metric-project-config-tags branch from 38b37eb to e4276b2 Compare March 9, 2026 16:49
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Additional Artifact Review Required

Changes to artifact directory files requires at least 2 approvals from core team members.

@dtaniwaki dtaniwaki force-pushed the fix/metric-project-config-tags branch 2 times, most recently from 5e2d95e to 9ec89fb Compare March 9, 2026 16:54
@dtaniwaki dtaniwaki changed the title fix: apply +tags from dbt_project.yml to metrics feat: support config.tags and +tags for metrics and semantic models Mar 9, 2026
@dtaniwaki dtaniwaki force-pushed the fix/metric-project-config-tags branch from 9ec89fb to a0b27bc Compare March 9, 2026 16:57
Signed-off-by: Daisuke Taniwaki <daisuketaniwaki@gmail.com>
@dtaniwaki dtaniwaki force-pushed the fix/metric-project-config-tags branch from a0b27bc to 0517ca5 Compare March 10, 2026 02:44
@dtaniwaki dtaniwaki changed the title feat: support config.tags and +tags for metrics and semantic models feat: add config.tags and +tags support for metrics Mar 10, 2026
@graciegoheen graciegoheen added the ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering label Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla:yes community This PR is from a community member ready_for_review Externally contributed PR has functional approval, ready for code review from Core engineering

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Apply tags config to metrics

2 participants