dbt-labs / dbt-semantic-interfaces

The shared semantic layer definitions that dbt-core and MetricFlow use.
Apache License 2.0
66 stars 13 forks source link

[Bug] Derived metric validation allows empty input metric set #269

Open tlento opened 6 months ago

tlento commented 6 months ago

Is this a new bug in dbt-semantic-interfaces?

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 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

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

Additional Context

No response