dbt-labs / dbt-labs/dbt-semantic-interfaces
[Bug] Derived metric validation false positive on "identical input measures"
- Dominant language
- Python
- Stars
- 103
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
### Is this a new bug in dbt-semantic-interfaces?
- [X] I believe this is a new bug in dbt-semantic-interfaces
- [X] I have searched the existing issues, and I could not find an existing issue for this bug
### Current Behavior
Running validation on a model with a metric specified like so:
```
metrics:
- name: revenue
alias: current_revenue
- name: revenue
offset_window: 1 month
alias: revenue_prev_month
```
Prints this warning:
```
15:07:37 Running with dbt=1.6.1
15:07:37 Registered adapter: snowflake=1.6.2
15:07:38 PydanticMetric revenue_growth_mom has multiple identical input measures specifications for measure revenue. This might be hiding a semantic error. Input measure specification: name='revenue' filter=None alias=None.
```
The issue here is we are running the input measures validator on derived metrics without accounting for the fact that a derived metric is made up of multiple metrics which might themselves be sourced from shared measures.
There's nothing a user can do to fix this or act upon it. Indeed, nothing is even broken - in this case the user wants to compute some expr based on a transformation of the same input metric. That transformation and alias will naturally apply to the measure input on the metrics, but we can't detect that at this level, so we raise the validation warning about shared input measures (duh) with a baffling "alias: None" in there (because the input measures don't have aliases set).
### Expected Behavior
We would expect this to pass validation cleanly, as nothing is wrong.
More generally, derived metric input validation should not be validating input measures. It should be validating input metrics.
### Steps To Reproduce
Define a derived metric that relies on two distinct transformations of the same input metric (offset or filter) with aliases properly set and run the validation in a mode that will print warnings.
### Relevant log output
_No response_
### Environment
```markdown
- OS:
- Python:
- dbt:
- dbt-semantic-interfaces:
```
### Additional Context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.