dbt Semantic Layer and Cube

Metrics Definitions in dbt's Semantic Layer and Cube

dbt 37,942 's Semantic Layer is built on MetricFlow, an Apache 2.0 engine (github.com/dbt-labs/metricflow (https://github.com/dbt-labs/metricflow 1,816 )) that turns metric requests into SQL with the right joins. Since dbt 1.12 the definitions sit on the models: semantic_model enables a model, columns become entities (join keys) and dimensions, and metrics declare simple, ratio or derived aggregations. The open-source mf command (pip 21,050 install "dbt-metricflow[dbt-postgres]": dbt-metricflow 0.15.0, MetricFlow 0.213.0 here) queries them locally; dbt's hosted platform serves them to BI tools.

Cube (github.com/cube-js/cube (https://github.com/cube-js/cube 20,949 ); Apache 2.0 backend, MIT client) is an independent semantic layer server: its YAML defines cubes with measures, dimensions, joins and pre-aggregations, which it builds in its own Cube Store and serves over SQL, REST and GraphQL APIs (from documentation, not run here).

Choose dbt's layer when the models already live in dbt, and Cube when applications also need its API and cache.