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-2526] Add ability to automatically create metrics from semantic model measures #8310

Merged
merged 8 commits into from
Aug 14, 2023

Conversation

QMalcolm
Copy link
Contributor

@QMalcolm QMalcolm commented Aug 3, 2023

resolves #7504

Problem

Many metrics are just simple metrics defined directly off measures. This work could be easily automated by adding a property to measures that indicates a simple metric should be created

Solution

The first step is to simply create a metric when create_metric: true is specified. If a create_metric value isn't specified in the raw measure, then create_metric will default to False. There are also a number of implications with partial parsing.

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/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

@QMalcolm QMalcolm added the Skip Changelog Skips GHA to check for changelog file label Aug 3, 2023
@cla-bot cla-bot bot added the cla:yes label Aug 3, 2023
@QMalcolm QMalcolm changed the title Ct 2526 support create metric measure property [CT-2526] Add ability to automatically create metrics from semantic model measures Aug 3, 2023
@codecov
Copy link

codecov bot commented Aug 3, 2023

Codecov Report

Merging #8310 (d97ffe9) into main (a433c31) will decrease coverage by 0.05%.
Report is 4 commits behind head on main.
The diff coverage is 90.90%.

@@            Coverage Diff             @@
##             main    #8310      +/-   ##
==========================================
- Coverage   86.28%   86.23%   -0.05%     
==========================================
  Files         174      174              
  Lines       25518    25536      +18     
==========================================
+ Hits        22017    22020       +3     
- Misses       3501     3516      +15     
Files Changed Coverage Δ
core/dbt/parser/partial.py 93.42% <71.42%> (-0.24%) ⬇️
core/dbt/contracts/files.py 94.54% <100.00%> (+0.02%) ⬆️
core/dbt/contracts/graph/manifest.py 93.76% <100.00%> (+0.01%) ⬆️
core/dbt/contracts/graph/unparsed.py 93.10% <100.00%> (+0.01%) ⬆️
core/dbt/parser/schema_yaml_readers.py 90.99% <100.00%> (+0.29%) ⬆️

... and 5 files with indirect coverage changes

@QMalcolm QMalcolm force-pushed the ct-2526--support-create-metric-measure-property branch from 8459820 to 233cb44 Compare August 3, 2023 21:54
@QMalcolm QMalcolm force-pushed the ct-2526--support-create-metric-measure-property branch from 233cb44 to 6c45e3b Compare August 3, 2023 22:19
@QMalcolm QMalcolm added semantic Issues related to the semantic layer and removed Skip Changelog Skips GHA to check for changelog file labels Aug 3, 2023
@QMalcolm QMalcolm marked this pull request as ready for review August 3, 2023 22:19
@QMalcolm QMalcolm requested a review from a team as a code owner August 3, 2023 22:19
@QMalcolm QMalcolm requested a review from aranke August 3, 2023 22:19
@QMalcolm QMalcolm force-pushed the ct-2526--support-create-metric-measure-property branch from 6c45e3b to c3a6671 Compare August 4, 2023 18:19
@QMalcolm QMalcolm force-pushed the ct-2526--support-create-metric-measure-property branch from c3a6671 to 4ff857f Compare August 4, 2023 18:20
@QMalcolm QMalcolm requested a review from peterallenwebb August 4, 2023 18:46
I was doing a demo earlier today of this branch (minus this commit)
and noticed something odd. When I changes a semantic model, metrics
that should have been technically uneffected would get dropped. Basically
if I made a change to a semantic model which had metrics in the same
file, and then ran parse, those metrics defined in the same file
would get dropped. Then with no other changes, if I ran parse again
they would come back. What was happening was that parsed metrics
and generated metrics were getting tracked the same way on the file
objects for partial parsing. In 0787a7c
we began dropping all metrics tracked in a file objects when changes
to semantic models were detected. Since parsed metrics and generated
metrics were being tracked together on the file object, the parsed
metrics were getting dropped as well. In this commit we begin separating
out the tracking of generated metrics and parsed metrics on the
file object, and now only drop the generated metrics when semantic
models have a detected change.
@QMalcolm QMalcolm force-pushed the ct-2526--support-create-metric-measure-property branch from a86b875 to f821b1c Compare August 4, 2023 21:07
@QMalcolm QMalcolm merged commit b045180 into main Aug 14, 2023
@QMalcolm QMalcolm deleted the ct-2526--support-create-metric-measure-property branch August 14, 2023 19:42
@graciegoheen graciegoheen added the user docs [docs.getdbt.com] Needs better documentation label Sep 25, 2023
@FishtownBuildBot
Copy link
Collaborator

Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#4127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes semantic Issues related to the semantic layer user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-2526] Create Metric node for measures with create_metric: true during parsing
4 participants