Skip to main content

Validations

MetricFlow has three types of built-in validations. The first is Parsing Validation, which ensures that the config files follow the schema MetricFlow expects to be able to be parsed into model objects.

Next is Semantic Validation, which occurs after we've built your model. We run a suite of tests to ensure the semantics of your model make sense. For example, we check to see if measure names are unique, or if Metrics referenced in materialization exist.

Finally, we run Data Warehouse validation, which checks to see if the semantic definitions in your model exist in your data warehouse. To test this, we run queries against your data warehouse to ensure the generated SQL for data sources, dimensions, and metrics will execute.

These three validation steps are blocking, meaning the first step must succeed before we try to validate the next part of your model.

The validation code for MetricFlow can be found here.

Parsing Validation

In this validation step, we ensure your config files follow the defined schema for each model object and can be parsed successfully into model objects. We validate the schema for the following core objects:

  • Data sources
  • Identifiers
  • Measures
  • Dimensions
  • Metrics
  • Materializations

Semantic Validation

In this validation step, we run arbitrary tests to ensure the semantics of your model are correct. The current semantic rules we check for are:

  1. Check that Data Sources with measures have a valid primary time dimension
  2. Check that there is only one primary identifier defined in each Data Source
  3. Check that there is only one primary identifier defined in each Data Source
  4. Dimension consistency
  5. Unique measures in Data Sources
  6. Measures in Metrics are valid
  7. Cumulative metrics are configured properly

Data Warehouse Validation

This type of validation runs checks against your Data Warehouse to make sure the generated SQL from MetricFlow will execute. We run the following checks

  • Check that measures and dimensions exist
  • Check that underlying tables for data sources exist
  • Check that the generated SQL for metrics will execute

How to run validations

For Transform users run

mql validate-configs

For MetricFlow users run

mf validate-configs