Skip to content

Commit c1f40f5

Browse files
Small code clean up for proxy_measure
1 parent 217703e commit c1f40f5

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

dbt_semantic_interfaces/transformations/proxy_measure.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def transform_model(semantic_manifest: PydanticSemanticManifest) -> PydanticSema
3838
continue
3939

4040
add_metric = True
41-
for metric in semantic_manifest.metrics:
42-
if metric.name == measure.name:
43-
if metric.type != MetricType.SIMPLE:
41+
for manifest_metric in semantic_manifest.metrics:
42+
if manifest_metric.name == measure.name:
43+
if manifest_metric.type != MetricType.SIMPLE:
4444
raise ModelTransformError(
4545
f"Cannot have metric with the same name as a measure ({measure.name}) that is not a "
4646
f"created mechanically from that measure using create_metric=True"
@@ -50,18 +50,19 @@ def transform_model(semantic_manifest: PydanticSemanticManifest) -> PydanticSema
5050
f"that measure"
5151
)
5252
add_metric = False
53+
break
5354

5455
if add_metric is True:
55-
metric = MeasureFeaturesToMetricNameMapper.build_metric_from_measure_configuration(
56+
new_metric = MeasureFeaturesToMetricNameMapper.build_metric_from_measure_configuration(
5657
measure=measure,
5758
semantic_model_name=semantic_model.name,
5859
fill_nulls_with=None,
5960
join_to_timespine=False,
6061
# we override the default here; this metric was explicitly created by the user.
6162
is_private=False,
6263
)
63-
metric.name = measure.name
64-
metric.type_params.measure = PydanticMetricInputMeasure(name=measure.name)
65-
semantic_manifest.metrics.append(metric)
64+
new_metric.name = measure.name
65+
new_metric.type_params.measure = PydanticMetricInputMeasure(name=measure.name)
66+
semantic_manifest.metrics.append(new_metric)
6667

6768
return semantic_manifest

0 commit comments

Comments
 (0)