metricflow
Translates a simple metric definition into reusable SQL and executes it against the SQL engine of your choice.
What it is and what it does
MetricFlow is a semantic layer that translates metric definitions into SQL queries optimized for your data warehouse. It abstracts away the complexity of multi-hop joins between fact and dimension tables, handles advanced metric types (ratio, expression, cumulative), and manages aggregation across different time granularities. The package compiles metric requests into a dataflow-based query plan, optimizes it, and renders engine-specific SQL.
MetricFlow is designed to work within the dbt ecosystem as a query compilation and SQL rendering library. It requires a working dbt project and dbt adapter to function. The package depends on 12 runtime libraries including jinja2, pydantic, sqlglot, and pyyaml to handle templating, validation, SQL parsing, and configuration. It supports Python 3.10 through 3.14 and is actively maintained.
Use it for:
- Define metrics once in code and automatically generate consistent SQL queries across multiple data warehouses.
- Build complex ratio metrics, cumulative metrics, and expressions that depend on multiple fact and dimension tables.
- Aggregate metrics to different time granularities without rewriting query logic.
- Maintain a centralized semantic layer for metrics used across analytics, BI tools, and reporting dashboards.
- Integrate metric definitions into version-controlled, testable metric logic within existing workflows.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
MetricFlow compiles metric definitions into reusable SQL queries, handling multi-hop joins, complex metric types, and aggregations across different time granularities.
Yes, if you need to centralize metric logic in code. MetricFlow is actively maintained, has no known vulnerabilities, carries a permissive Apache-2.0 license, and installs with low friction. It solves a real problem—metric consistency and reusability—but requires a dbt project and adapter to work, so it is not a standalone tool. Best suited for teams already invested in dbt.
Install
metricflow on PyPI
pip
pip install metricflowuv
uv add metricflowpoetry
poetry add metricflowInstalling metricflow
Before you install
Low install friction with a pure Python wheel. Active maintenance with a release 2 days ago. Supports Python 3.10 through 3.14. Requires a working dbt project and dbt adapter to function; optional system dependencies include Postgres and Graphviz.
License in practice
Apache-2.0 permissive license. Version 0.212.0 is covered by Apache-2.0 (versions 0.209.0 and greater); earlier versions were under AGPL or BSL, so this version carries no copyleft obligations.
Quickstart
pip install metricflow
import metricflow
# Requires a working dbt project and dbt adapter configured before use
Requires a working dbt project, a dbt adapter, and optionally Postgres or Graphviz installed on the system.
Verify before relying
- Whether the package can be used standalone or strictly requires dbt project integration for all operations.
- Performance characteristics and scalability limits for large metric definitions or complex joins.
- Whether Postgres and Graphviz are required or only needed for specific features.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (<3.15,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 12 — importlib-metadata, jinja2, jsonschema, more-itertools, pydantic, python-dateutil, pyyaml, rapidfuzz, referencing, sqlglot, tabulate, typing-extensions |
| Maintenance | actively maintained — 2 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,310,188/month — #2,335 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: metricflow-0.212.0-py3-none-any.whl
Tags
More Database packages
psycopg2-binary is a PostgreSQL database…
copyleft · top 1,000 on PyPI
redisPython client library for connecting to and…
permissive · top 1,000 on PyPI
ydbYDB Python SDK is the official client library…
permissive · top 1,000 on PyPI
snowflake-connector-pythonConnects Python applications to Snowflake data…
permissive · top 1,000 on PyPI
sqlparsesqlparse tokenizes SQL text into a tree of…
permissive · top 1,000 on PyPI
dbt-adaptersProvides base adapter protocols and shared…
permissive · top 1,000 on PyPI
dbt-metricflowBundles dbt-core and MetricFlow with compatible…
permissive · top 15,000 on PyPI
dbt-semantic-interfacesProvides shared semantic class definitions,…
permissive · top 1,000 on PyPI
dbt-coredbt-core transforms raw data in a warehouse…
permissive · top 1,000 on PyPI
dbt-sl-sdkA Python client library for querying dbt's…
unclear · top 15,000 on PyPI
dbt-bigquerydbt-bigquery is a dbt adapter that enables data…
permissive · top 5,000 on PyPI
azure-monitor-querymetricsQuery and retrieve numerical metrics data from…
permissive · top 15,000 on PyPI
dbt-trinoA dbt adapter that connects dbt projects to…
permissive · top 15,000 on PyPI
aws-embedded-metricsGenerates CloudWatch metrics embedded within…
permissive · top 5,000 on PyPI
dbt-osmosisdbt-osmosis is a CLI tool and Python package…
permissive · top 15,000 on PyPI
airflow-dbtProvides Airflow operators that wrap dbt CLI…
permissive · top 15,000 on PyPI