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

Propagate the measure label when using create_metric option #10536

Conversation

aliceliu
Copy link
Contributor

@aliceliu aliceliu commented Aug 7, 2024

Resolves #10538

Problem

When using create_metric on a measure, the label of the measure is not propagated to the metric

Solution

Set metric label to be measure label if it exists

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.

@cla-bot cla-bot bot added the cla:yes label Aug 7, 2024
Copy link
Contributor

github-actions bot commented Aug 7, 2024

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.

Copy link
Contributor Author

aliceliu commented Aug 7, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @aliceliu and the rest of your teammates on Graphite Graphite

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.84%. Comparing base (21a4633) to head (e867392).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10536   +/-   ##
=======================================
  Coverage   88.84%   88.84%           
=======================================
  Files         180      180           
  Lines       22717    22720    +3     
=======================================
+ Hits        20182    20186    +4     
+ Misses       2535     2534    -1     
Flag Coverage Δ
integration 86.07% <ø> (+<0.01%) ⬆️
unit 62.35% <ø> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Unit Tests 62.35% <ø> (+0.03%) ⬆️
Integration Tests 86.07% <ø> (+<0.01%) ⬆️

@aliceliu aliceliu force-pushed the 08-06-support_using_the_measure_label_when_using_create_metric_option branch from 9342b0a to be26928 Compare August 7, 2024 00:21
@aliceliu aliceliu changed the title Support using the measure label when using create_metric option Propagate the measure label when using create_metric option Aug 7, 2024
@aliceliu aliceliu marked this pull request as ready for review August 7, 2024 00:36
@aliceliu aliceliu requested a review from a team as a code owner August 7, 2024 00:36
@github-actions github-actions bot added the community This PR is from a community member label Aug 7, 2024
@aliceliu aliceliu requested a review from QMalcolm August 7, 2024 00:37
Copy link
Contributor

@QMalcolm QMalcolm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. It would probably be worthwhile to add a test which checks the state of the created metric when the related measure does not have a label set, however this is not blocking.

Context

When _create_metric, which creates a metric from a measure, was written, measures did not have labels. It seems that when label was added to the measure class, we did not think to add it here. That is an oversight, but I can see how that happened.

Implications

For metrics created from measures, in order to get the correct label, a full reparse will be necessary. This is because partial parsing only reparses an object is the input for the object has changed. Thus, without a full parsing, the relevant metrics will only get updated if the underlying semantic model is modified somehow.

TL;DR

Looks good. People will need to run dbt parse --no-partial-parse to ensure all existing measures with labels that create metrics properly propagate the label.

@aliceliu aliceliu force-pushed the 08-06-support_using_the_measure_label_when_using_create_metric_option branch from be26928 to 402c4c6 Compare August 7, 2024 17:22
@aliceliu aliceliu force-pushed the 08-06-support_using_the_measure_label_when_using_create_metric_option branch from 402c4c6 to e867392 Compare August 7, 2024 17:36
@aliceliu
Copy link
Contributor Author

aliceliu commented Aug 7, 2024

@QMalcolm thanks for the context! I updated the test. I don't have permission to merge so I'll leave the merging to you

@QMalcolm QMalcolm merged commit 7f57dd5 into main Aug 7, 2024
66 checks passed
@QMalcolm QMalcolm deleted the 08-06-support_using_the_measure_label_when_using_create_metric_option branch August 7, 2024 20:06
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Measure labels for create_metric = true don't propogate
3 participants