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:
- Check that Data Sources with measures have a valid primary time dimension
- Check that there is only one primary identifier defined in each Data Source
- Check that there is only one primary identifier defined in each Data Source
- Dimension consistency
- Unique measures in Data Sources
- Measures in Metrics are valid
- 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