Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions dbt_semantic_interfaces/transformations/proxy_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ def transform_model(semantic_manifest: PydanticSemanticManifest) -> PydanticSema
continue

add_metric = True
for metric in semantic_manifest.metrics:
if metric.name == measure.name:
if metric.type != MetricType.SIMPLE:
for manifest_metric in semantic_manifest.metrics:
if manifest_metric.name == measure.name:
if manifest_metric.type != MetricType.SIMPLE:
raise ModelTransformError(
f"Cannot have metric with the same name as a measure ({measure.name}) that is not a "
f"created mechanically from that measure using create_metric=True"
Expand All @@ -50,18 +50,19 @@ def transform_model(semantic_manifest: PydanticSemanticManifest) -> PydanticSema
f"that measure"
)
add_metric = False
break

if add_metric is True:
metric = MeasureFeaturesToMetricNameMapper.build_metric_from_measure_configuration(
new_metric = MeasureFeaturesToMetricNameMapper.build_metric_from_measure_configuration(
measure=measure,
semantic_model_name=semantic_model.name,
fill_nulls_with=None,
join_to_timespine=False,
# we override the default here; this metric was explicitly created by the user.
is_private=False,
)
metric.name = measure.name
metric.type_params.measure = PydanticMetricInputMeasure(name=measure.name)
semantic_manifest.metrics.append(metric)
new_metric.name = measure.name
new_metric.type_params.measure = PydanticMetricInputMeasure(name=measure.name)
semantic_manifest.metrics.append(new_metric)

return semantic_manifest
Loading