-
Notifications
You must be signed in to change notification settings - Fork 26
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
feat(dbt sync): Support metric key remapping #311
Conversation
1b67a44
to
c97eb59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Left a small suggestion.
meta = metric.get("meta", {}) | ||
kwargs = meta.pop("superset", {}) | ||
metric_meta = parse_metric_meta( | ||
metric.get("meta", metric.get("config", {}).get("meta", {})), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move this logic to the parse_metric_meta
, it would make it easier to understand. Here we'd simply do:
metric_meta = parse_metric_meta(metric)
And the parse_metric_meta
function would handle the retrieval of meta
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense! let me get that done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@betodealmeida I implemented a base MetricSchema (shared across OG/MF/etc) o that I can also use it as the type hint for this helper. This caused some additional updates to other files.
""" | ||
Parses the metric's meta information. | ||
""" | ||
kwargs = metric.get("meta", {}).pop("superset", {}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still need to use .get("meta", {})
here as logic to handle meta
|| config.meta
for dbt Cloud will be added in a future PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double approved!
dbt introduced new restrictions to metric names with MetricFlow (for example, it's no longer possible to have
__
in metric names). As a consequence, in order to upgrade to a supported version customers have to update all their metric names according to new rules. The metric mapping with Preset happens based on the metric name, so a re-name in dbt would result in new metrics in Preset, leaving old metrics out of sync.This PR introduces a way to map a dbt metric with a Preset metric with diverging names, to minimize the impact of this change.
This PR also improves the
meta
handling in general for metrics (so that Preset-specific fields can be controlled through dbt) and also improves the handling for the metriclabel
(it wasn't being pulled from MetricFlow metrics).