The problem I’m having
dbt Semantic Layer throws an error that’s not clear to me what’s wrong.
It starts doing this when I add a second metric of type ‘rate’. Both the metrics in the numerator and denominator are defined and working. As soon as I add the rate however, it starts giving an error.
It is worth to note that it does work with the first rate metric, but for some reason when I add the 2nd one it starts giving the error that is mentioning the measure behind the simple metric that is the denominator.
Encountered an error: error querying against the semantic layer: Matched with [MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name='some_measure', non_additive_dimension_spec=None, fill_nulls_with=None), fill_nulls_with=None, offset_window=None, offset_to_grain=None, culmination_description=None, filter_specs=(), alias=None, before_aggregation_time_spine_join_description=None, after_aggregation_time_spine_join_description=None), MetricInputMeasureSpec(measure_spec=MeasureSpec(element_name='some_measure', non_additive_dimension_spec=None, fill_nulls_with=None), fill_nulls_with=None, offset_window=None, offset_to_grain=None, culmination_description=None, filter_specs=(), alias=None, before_aggregation_time_spine_join_description=None, after_aggregation_time_spine_join_description=None)] for measure instance MeasureInstance(defined_from=(SemanticModelElementReference(semantic_model_name='some_model', element_name='some_measure'),), associated_columns=(ColumnAssociation(column_name='searches', single_column_correlation_key=SingleColumnCorrelationKey(PYDANTIC_BUG_WORKAROUND=True)),), spec=MeasureSpec(element_name='some_measure', non_additive_dimension_spec=None, fill_nulls_with=None), aggregation_state=AggregationState.COMPLETE).
The Code
the measurements in the semantic layer yaml looks like this:
measures:
- name: measure_1
description:
agg: sum
- name: some_measure
description:
agg: sum
- name: measure_3
description:
agg: sum
The metrics yaml looks like this:
metrics:
# We first define the base metrics because of order of parsing in the IDE,
# and afterwards we parse the metrics that are using these base metrics in their definitions
# BASE METRICS
- name: metric_1
description:
type: simple
label: metric_1
type_params:
measure: measure_1
- name: some_metric
description:
type: simple
label: some_metric
type_params:
measure: some_measure
- name: metric_2
description:
type: simple
label: metric_2
type_params:
measure: measure_2
# RATES
- name:metric_1_rate
description:
type: ratio
label: metric_1_rate
type_params:
numerator: metric_1
denominator: some_metric
- name: metric_2_rate
description:
type: ratio
label: metric_2_rate
type_params:
numerator: metric_2
denominator: some_metric
What I’ve already tried
renaming some_metric
so that’s it has a different name as the measure.
when I remove only the metric_2_rate metric , I don’t get the error.
so the metric_1_rate is working, even though it uses the same denominator!