/databricks-metric-views
Unity Catalog metric views: define, create, query, and manage governed business metrics in YAML. Use when building standardized KPIs, revenue metrics, order analytics, or any reusable business metrics that need consistent definitions across teams and tools.
$ npx -y skills add databricks/databricks-agent-skills --skill databricks-metric-views --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/databricks-metric-views
Context preview
The summary Claude sees to decide when to auto-load this skill.
Unity Catalog metric views: define, create, query, and manage governed business metrics in YAML. Use when building standardized KPIs, revenue metrics, order analytics, or any reusable business metrics that need consistent definitions across teams and tools.
SKILL.md
databricks-metric-views.SKILL.mdname: databricks-metric-views
description: "Unity Catalog metric views: define, create, query, and manage governed business metrics in YAML. Use when building standardized KPIs, revenue metrics, order analytics, or any reusable business metrics that need consistent definitions across teams and tools."
compatibility: Requires databricks CLI (>= v1.0.0)
metadata:
version: "0.1.0"
parent: databricks-core
Unity Catalog Metric Views
Define reusable, governed business metrics in YAML that separate measure definitions from dimension groupings for flexible querying.
When to Use
Use this skill when:
- Defining **standardized business metrics** (revenue, order counts, conversion rates)
- Building **KPI layers** shared across dashboards, Genie, and SQL queries
- Creating metrics with **complex aggregations** (ratios, distinct counts, filtered measures)
- Defining **window measures** (moving averages, running totals, period-over-period, YTD)
- Modeling **star or snowflake schemas** with joins in metric definitions
- Enabling **materialization** for pre-computed metric aggregations
Prerequisites
- **Databricks Runtime 17.2+** (for YAML version 1.1); **17.3+** for semantic metadata (`synonyms` / `display_name` / `format`)
- SQL warehouse with `CAN USE` permissions
- `SELECT` on source tables, `CREATE TABLE` + `USE SCHEMA` in the target schema
Quick Start
Inspect Source Table Schema
Before authoring a metric view, inspect the source tables. Use `discover-schema` as the default — one call returns columns, types, sample rows, null counts, and row count. If you only know the schema, list tables first with `query "SHOW TABLES IN ..."`.
`databricks experimental aitools tools discover-schema catalog.schema.orders catalog.schema.customers`
For dimensions and measures, probe distribution beyond sampling — cardinality of candidate dimensions, min/max/percentiles for measures, top categorical values. Write aggregate SQL through `databricks experimental aitools tools query --warehouse <WH> "..."`. Both commands auto-pick the default warehouse; set `DATABRICKS_WAREHOUSE_ID` or pass `--warehouse <ID>` to override.
> The `databricks experimental aitools tools` subcommands are experimental — subject to change between CLI versions. Confirm availability with `databricks experimental aitools tools --help` before relying on them; see [CLI Execution](#cli-execution) for the stable Statement Execution API fallback.
Create a Metric View
CREATE OR REPLACE VIEW catalog.schema.orders_metrics
WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
source: catalog.schema.orders
comment: "Orders KPIs for sales analysis"
filter: order_date > '2020-01-01'
dimensions:
- name: Order Month
expr: DATE_TRUNC('MONTH', order_date)
comment: "Month of order"
- name: Order Status
expr: CASE
WHEN status = 'O' THEN 'Open'
WHEN status = 'P' THEN 'Processing'
WHEN status = 'F' THEN 'Fulfilled'
END
comment: "Human-readable order status"
measures:
- name: Order Count
expr: COUNT(1)
- name: Total Revenue
expr: SUM(total_price)
comment: "Sum of total price"
- name: Revenue per Customer
expr: SUM(total_price) / COUNT(DISTINCT customer_id)
comment: "Average revenue per unique customer"
$$Query a Metric View
All measures must use the `MEASURE()` function. `SELECT *` is NOT supported.
SELECT
`Order Month`,
`Order Status`,
MEASURE(`Total Revenue`) AS total_revenue,
MEASURE(`Order Count`) AS order_count
FROM catalog.schema.orders_metrics
WHERE extract(year FROM `Order Month`) = 2024
GROUP BY ALL
ORDER BY ALL
Reference Files
| Topic | File | Description | |-------|------|-------------| | YAML Syntax | [references/yaml-reference.md](references/yaml-reference.md) | Complete YAML spec: dimensions, measures, joins, materialization | | Patterns & Examples | [references/patterns.md](references/patterns.md) | Common patterns: star schema, snowflake, filtered measures, window measures, ratios | | Multi-source build (Advisor) | [references/metric-view-advisor.md](references/metric-view-advisor.md) | Guided workflow to build metric views from gold schemas, dashboards, SQL queries, Genie spaces, or KPI files — analysis, overlap detection, deploy |
Guided, multi-source build (Metric View Advisor)
For the single-table create/query patterns above, use this skill directly. When the user wants to **build metric views from existing assets** — gold/fact schemas, AI/BI dashboards, SQL query files, Genie spaces, or KPI spreadsheets — combine multiple sources, deduplicate against views that already exist, and walk deployment end to end, use the **Metric View Advisor** in [`references/metric-view-advisor.md`](references/metric-view-advisor.md). It builds on this skill's baseline spec and adds the multi-source analysis, overlap detection, and an interactive build/deploy flow. Load it when the user asks to "formalize our KPIs," "build a metric/semantic layer from our tables/dashboards/queries," or otherwise wants a guided build rather than authoring one view by hand.
SQL Operations
Create Metric View
CREATE OR REPLACE VIEW catalog.schema.orders_metrics
WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
comment: "Orders KPIs for sales analysis"
source: catalog.schema.orders
filter: order_date > '2020-01-01'
dimensions:
- name: Order Month
expr: DATE_TRUNC('MONTH', order_date)
comment: "Month of order"
- name: Order Status
expr: status
measures:
- name: Order Count
expr: COUNT(1)
- name: Total Revenue
expr: SUM(total_price)
comment: "Sum of total price"
$$;Query Metric View
SELECT
`Order Month`,
MEASURE(`Total Revenue`) AS total_revenue,
MEASURE(`Order Count`) AS order_count
FROM catalog.schema.orders_metrics
WHERE extract(year FROM `Order Month`) = 2024
GROUP BY ALL
ORDER BY ALL
LIMIT 10
Read more
name: databricks-metric-views description: "Unity Catalog metric views: define, create, query, and manage governed business metrics in YAML. Use when building standardized KPIs, revenue metrics, order analytics, or any reusable business metrics that need consistent definitions across teams and tools." compatibility: Requires databricks CLI (>= v1.0.0) metadata: version: "0.1.0" parent: databricks-core
Unity Catalog Metric Views
Define reusable, governed business metrics in YAML that separate measure definitions from dimension groupings for flexible querying.
When to Use
Use this skill when:
- Defining **standardized business metrics** (revenue, order counts, conversion rates)
- Building **KPI layers** shared across dashboards, Genie, and SQL queries
- Creating metrics with **complex aggregations** (ratios, distinct counts, filtered measures)
- Defining **window measures** (moving averages, running totals, period-over-period, YTD)
- Modeling **star or snowflake schemas** with joins in metric definitions
- Enabling **materialization** for pre-computed metric aggregations
Prerequisites
- **Databricks Runtime 17.2+** (for YAML version 1.1); **17.3+** for semantic metadata (`synonyms` / `display_name` / `format`)
- SQL warehouse with `CAN USE` permissions
- `SELECT` on source tables, `CREATE TABLE` + `USE SCHEMA` in the target schema
Quick Start
Inspect Source Table Schema
Before authoring a metric view, inspect the source tables. Use `discover-schema` as the default — one call returns columns, types, sample rows, null counts, and row count. If you only know the schema, list tables first with `query "SHOW TABLES IN ..."`.
`databricks experimental aitools tools discover-schema catalog.schema.orders catalog.schema.customers`
For dimensions and measures, probe distribution beyond sampling — cardinality of candidate dimensions, min/max/percentiles for measures, top categorical values. Write aggregate SQL through `databricks experimental aitools tools query --warehouse <WH> "..."`. Both commands auto-pick the default warehouse; set `DATABRICKS_WAREHOUSE_ID` or pass `--warehouse <ID>` to override.
> The `databricks experimental aitools tools` subcommands are experimental — subject to change between CLI versions. Confirm availability with `databricks experimental aitools tools --help` before relying on them; see [CLI Execution](#cli-execution) for the stable Statement Execution API fallback.
Create a Metric View
CREATE OR REPLACE VIEW catalog.schema.orders_metrics
WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
source: catalog.schema.orders
comment: "Orders KPIs for sales analysis"
filter: order_date > '2020-01-01'
dimensions:
- name: Order Month
expr: DATE_TRUNC('MONTH', order_date)
comment: "Month of order"
- name: Order Status
expr: CASE
WHEN status = 'O' THEN 'Open'
WHEN status = 'P' THEN 'Processing'
WHEN status = 'F' THEN 'Fulfilled'
END
comment: "Human-readable order status"
measures:
- name: Order Count
expr: COUNT(1)
- name: Total Revenue
expr: SUM(total_price)
comment: "Sum of total price"
- name: Revenue per Customer
expr: SUM(total_price) / COUNT(DISTINCT customer_id)
comment: "Average revenue per unique customer"
$$Query a Metric View
All measures must use the `MEASURE()` function. `SELECT *` is NOT supported.
SELECT `Order Month`, `Order Status`, MEASURE(`Total Revenue`) AS total_revenue, MEASURE(`Order Count`) AS order_count FROM catalog.schema.orders_metrics WHERE extract(year FROM `Order Month`) = 2024 GROUP BY ALL ORDER BY ALL
Reference Files
| Topic | File | Description | |-------|------|-------------| | YAML Syntax | [references/yaml-reference.md](references/yaml-reference.md) | Complete YAML spec: dimensions, measures, joins, materialization | | Patterns & Examples | [references/patterns.md](references/patterns.md) | Common patterns: star schema, snowflake, filtered measures, window measures, ratios | | Multi-source build (Advisor) | [references/metric-view-advisor.md](references/metric-view-advisor.md) | Guided workflow to build metric views from gold schemas, dashboards, SQL queries, Genie spaces, or KPI files — analysis, overlap detection, deploy |
Guided, multi-source build (Metric View Advisor)
For the single-table create/query patterns above, use this skill directly. When the user wants to **build metric views from existing assets** — gold/fact schemas, AI/BI dashboards, SQL query files, Genie spaces, or KPI spreadsheets — combine multiple sources, deduplicate against views that already exist, and walk deployment end to end, use the **Metric View Advisor** in [`references/metric-view-advisor.md`](references/metric-view-advisor.md). It builds on this skill's baseline spec and adds the multi-source analysis, overlap detection, and an interactive build/deploy flow. Load it when the user asks to "formalize our KPIs," "build a metric/semantic layer from our tables/dashboards/queries," or otherwise wants a guided build rather than authoring one view by hand.
SQL Operations
Create Metric View
CREATE OR REPLACE VIEW catalog.schema.orders_metrics
WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
comment: "Orders KPIs for sales analysis"
source: catalog.schema.orders
filter: order_date > '2020-01-01'
dimensions:
- name: Order Month
expr: DATE_TRUNC('MONTH', order_date)
comment: "Month of order"
- name: Order Status
expr: status
measures:
- name: Order Count
expr: COUNT(1)
- name: Total Revenue
expr: SUM(total_price)
comment: "Sum of total price"
$$;Query Metric View
SELECT `Order Month`, MEASURE(`Total Revenue`) AS total_revenue, MEASURE(`Order Count`) AS order_count FROM catalog.schema.orders_metrics WHERE extract(year FROM `Order Month`) = 2024 GROUP BY ALL ORDER BY ALL LIMIT 10
Skills for AI coding assistants (Claude Code, Cursor, etc.) that provide Databricks-specific guidance.
Repo: databricks/databricks-agent-skills
Other skills on databricks-agent-skills.
- /databricks-agent-bricks
Create Agent Bricks: Knowledge Assistants (KA) for document Q&A and Supervisor Agents for multi-agent orchestration (MAS).
Open skill - /databricks-ai-functions
Use Databricks built-in AI Functions (ai_classify, ai_extract, ai_summarize, ai_mask, ai_translate, ai_fix_grammar, ai_gen, ai_analyze_sentiment, ai_similarity, ai_parse_document, ai_prep_search, ai_query, ai_forecast) to add AI capabilities directly to SQL and PySpark pipelines
Open skill - /databricks-aibi-dashboards
Create Databricks AI/BI dashboards. Must use when creating, updating, or deploying Lakeview dashboards as Databricks Dashboard have a unique json structure. CRITICAL: You MUST test ALL SQL queries via CLI BEFORE deploying. Follow guidelines strictly.
Open skill - /databricks-app-design
Design the UX of custom-code Databricks Apps (AppKit/React) data screens — KPI/overview pages, reports, charts, tables, and Genie/chat data assistants — mapped to concrete AppKit components. Use when BUILDING or reviewing the UI of an AppKit/React app that displays data or
Open skill - /databricks-apps-python
Python backend for Databricks Apps — FastAPI (default), Flask, Dash, Streamlit, Gradio, Reflex. **Default for a new Databricks App is `databricks-apps` (AppKit — Node/TypeScript/React) — reach for it first.** Use this skill only when the user asks for a Python backend, extends
Open skill - /databricks-apps
Build apps on Databricks Apps platform. Use when asked to create data apps, analytics tools, or custom interactive visualizations. A plain \"create a dashboard\" request means a managed AI/BI (Lakeview) dashboard → use databricks-aibi-dashboards, not this skill. Evaluates data
Open skill

