Skip to content

Commit 82ed4b4

Browse files
Get MF using the new dsi transformations (#1877)
Depends on #1876 Upstream PR bumps the dsi version, implicitly updating tests to using the default ruleset from dsi. We can't do that for production MF rn because MF uses an extra transformation internally, so this PR adds all the newer built in PRs from dsi to metricflow-semantics/metricflow_semantics/model/dbt_manifest_parser.py to be used in real circumstances. (If time was less limited before coalesce, I'd prefer to move the rule upstream if possible, but I don't want to pick up extra work before code freeze.) Edit: There's also a rule (AddInputMeasuresToMetrics) that only works in dsi. It probably merits a refactor/rewrite later to clean up the usage code here, but I'd rather prioritize getting this updated here for now.
1 parent 5b55953 commit 82ed4b4

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Features
2+
body: Add new transformations to production from dsi that produce metrics from old-style measures.
3+
time: 2025-10-02T17:12:48.436607-07:00
4+
custom:
5+
Author: theyostalservice
6+
Issue: "387"

metricflow-semantics/metricflow_semantics/model/dbt_manifest_parser.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
from dbt_semantic_interfaces.implementations.semantic_manifest import (
44
PydanticSemanticManifest,
55
)
6-
from dbt_semantic_interfaces.transformations.boolean_measure import (
7-
BooleanMeasureAggregationRule,
6+
from dbt_semantic_interfaces.transformations.flatten_simple_metrics_with_measure_inputs import (
7+
FlattenSimpleMetricsWithMeasureInputsRule,
88
)
9-
from dbt_semantic_interfaces.transformations.convert_count import ConvertCountToSumRule
10-
from dbt_semantic_interfaces.transformations.convert_median import (
11-
ConvertMedianToPercentileRule,
12-
)
13-
from dbt_semantic_interfaces.transformations.cumulative_type_params import SetCumulativeTypeParamsRule
149
from dbt_semantic_interfaces.transformations.names import LowerCaseNamesRule
1510
from dbt_semantic_interfaces.transformations.proxy_measure import CreateProxyMeasureRule
11+
from dbt_semantic_interfaces.transformations.pydantic_rule_set import PydanticSemanticManifestTransformRuleSet
12+
from dbt_semantic_interfaces.transformations.replace_input_measures_with_simple_metrics_transformation import (
13+
ReplaceInputMeasuresWithSimpleMetricsTransformationRule,
14+
)
1615
from dbt_semantic_interfaces.transformations.semantic_manifest_transformer import (
1716
PydanticSemanticManifestTransformer,
1817
)
@@ -27,17 +26,21 @@ def parse_manifest_from_dbt_generated_manifest(manifest_json_string: str) -> Pyd
2726
# this time, which causes failures with input measure resolution.
2827
# TODO: remove this transform call once the upstream changes are integrated into our dependency tree
2928
# TODO: align rules between DSI, here, and MFS (if possible!)
29+
rule_set = PydanticSemanticManifestTransformRuleSet()
3030
rules = (
3131
# Primary
3232
(LowerCaseNamesRule(),),
33-
# Secondary
33+
# Secondary - broken out into groups because we run DedupeMetricInputMeasuresRule in the middle.
3434
(
35-
CreateProxyMeasureRule(),
36-
BooleanMeasureAggregationRule(),
37-
ConvertCountToSumRule(),
38-
ConvertMedianToPercentileRule(),
35+
*rule_set.legacy_measure_update_rules,
3936
DedupeMetricInputMeasuresRule(), # Remove once fix is in core
40-
SetCumulativeTypeParamsRule(),
37+
# These individual rules come from rule_set.convert_legacy_measures_to_metrics_rules, but
38+
# dsi requires AddInputMetricMeasuresRule, and metricflow requires that we do NOT run that rule
39+
# as it is incompatible with a parser like dbt-core that pre-populates input measures.
40+
CreateProxyMeasureRule(),
41+
FlattenSimpleMetricsWithMeasureInputsRule(),
42+
ReplaceInputMeasuresWithSimpleMetricsTransformationRule(),
43+
*rule_set.general_metric_update_rules,
4144
),
4245
)
4346
model = PydanticSemanticManifestTransformer.transform(raw_model, rules)

0 commit comments

Comments
 (0)