Skip to main content

Best practices

Putting it all together​

  • πŸ“Š We've walked through creating semantic models and metrics for basic coverage of a key business area.
  • πŸ” In doing so we've looked at how to refactor a frozen rollup into a dynamic, flexible new life in the Semantic Layer.

Best practices​

  • βœ… Prefer normalization when possible to allow MetricFlow to denormalize dynamically for end users.
  • βœ… Use marts to denormalize when needed, for instance grouping tables together into richer components, or getting measures on dimensional tables attached to a table with a time spine.
  • βœ… When source data is well normalized you can build semantic models on top of staging models.
  • βœ… Prefer computing values in measures and metrics when possible as opposed to in frozen rollups.
  • ❌ Don't directly refactor the code you have in production, build in parallel so you can audit the Semantic Layer output and deprecate old marts gracefully.

Key commands​

  • πŸ”‘ Use dbt parse to generate a fresh semantic manifest.
  • πŸ”‘ Use dbt sl list dimensions --metrics [metric name] to check that you're increasing dimensionality as you progress.
  • πŸ”‘ Use dbt sl query [query options] to preview the output from your metrics as you develop.

Next steps​

  • πŸ—ΊοΈ Use these best practices to map out your team's plan to incrementally adopt the Semantic Layer.
  • πŸ€— Get involved in the community and ask questions, help craft best practices, and share your progress in building a dbt Semantic Layer.
  • Validate semantic nodes in CI to ensure code changes made to dbt models don't break these metrics.

The dbt Semantic Layer is the biggest paradigm shift thus far in the young practice of analytics engineering. It's ready to provide value right away, but is most impactful if you move your project towards increasing normalization, and allow MetricFlow to do the denormalization for you with maximum dimensionality.

We will be releasing more resources soon covering implementation of the Semantic Layer in dbt Cloud with various integrated BI tools. This is just the beginning, hopefully this guide has given you a path forward for building your data platform in this new era. Refer to dbt Semantic Layer FAQs for more information.

0