dbt-labs / dbt-labs/dbt-semantic-interfaces

[Bug] Derived metric validation allows empty input metric set

Open
#269 0 comments 0 reactions 1 assignee Claimed by @tlento View on GitHub
bug
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

An end user has reported a problem with a set.intersection() error in MetricFlow, which was ultimately caused by a mis-configured derived metric defined with no metric inputs. See the [community slack thread](https://getdbt.slack.com/archives/C02CCBBBR1D/p1709071745469519?thread_ts=1709053116.764719&cid=C02CCBBBR1D) for more details.

In looking at the derived metric validation logic, there is no check that the metric inputs are non-empty, only a check that all inputs provided exist.

### Expected Behavior

If a metric config has derived metrics with no inputs specified, semantic validation should fail with an informative message.

### Steps To Reproduce

Create a metric with a spec like this:

```
metrics:
- name: bad_derived_metric
type: derived
description: "a bad derived metric"
type_params:
expr: "2 + 2"
```

This will pass validation.

### Relevant log output

_No response_

### Environment

```markdown
- OS:
- Python:
- dbt:
- dbt-semantic-interfaces: 0.4.x through current main
```

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.