metricflow icon indicating copy to clipboard operation
metricflow copied to clipboard

Metrics accepting multiple measures can fail if no group by elements requested

Open tlento opened this issue 2 years ago • 0 comments

Describe the bug When we have a metric based on multiple measures originating from different data sources, such as a ratio metric with a numerator and denominator computed from different tables or with different constraints, queries against that metric will fail if no group by element is requested.

As a practical matter this should be quite rare for the following reasons:

  1. The CLI does not allow a query with an empty dimension list
  2. The dominant majority of queries for metrics will group them by metric_time (or some other relevant time dimension), since Metricflow's initial metric offering is fundamentally built around measures computed across time

Steps To Reproduce Steps to reproduce the behavior:

  1. Add a test case to the configured test case config or the dataflow to sql plan conversion tests for bookings_per_listing with no dimensions selected
  2. Observe the rendered SQL generates an empty ON statement in the join
  3. Presumably the query will also fail, haven't tried running it

Expected behavior We'd expect the join to be written correctly for this case, or else for such queries to be disallowed at the API level and to fail with a helpful error message.

Version: Metricflow 0.100.2

tlento avatar Jul 13 '22 02:07 tlento