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.
Creates and queries governed business metrics in YAML for standardized KPIs and analytics across Databricks.
/plugin marketplace add https://www.claudepluginhub.com/api/plugins/databricks-solutions-databricks-ai-dev-kit/marketplace.json/plugin install databricks-solutions-databricks-ai-dev-kit@cpd-databricks-solutions-databricks-ai-dev-kitThis skill inherits all available tools. When active, it can use any tool Claude has access to.
patterns.mdyaml-reference.mdDefine reusable, governed business metrics in YAML that separate measure definitions from dimension groupings for flexible querying.
Use this skill when:
CAN USE permissionsSELECT on source tables, CREATE TABLE + USE SCHEMA in the target schemaCREATE 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: 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"
$$
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
| Topic | File | Description |
|---|---|---|
| YAML Syntax | yaml-reference.md | Complete YAML spec: dimensions, measures, joins, materialization |
| Patterns & Examples | patterns.md | Common patterns: star schema, snowflake, filtered measures, window measures, ratios |
Use the manage_metric_views tool for all metric view operations:
| Action | Description |
|---|---|
create | Create a metric view with dimensions and measures |
alter | Update a metric view's YAML definition |
describe | Get the full definition and metadata |
query | Query measures grouped by dimensions |
drop | Drop a metric view |
grant | Grant SELECT privileges to users/groups |
manage_metric_views(
action="create",
full_name="catalog.schema.orders_metrics",
source="catalog.schema.orders",
or_replace=True,
comment="Orders KPIs for sales analysis",
filter_expr="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"},
],
)
manage_metric_views(
action="query",
full_name="catalog.schema.orders_metrics",
query_measures=["Total Revenue", "Order Count"],
query_dimensions=["Order Month"],
where="extract(year FROM `Order Month`) = 2024",
order_by="ALL",
limit=100,
)
manage_metric_views(
action="describe",
full_name="catalog.schema.orders_metrics",
)
manage_metric_views(
action="grant",
full_name="catalog.schema.orders_metrics",
principal="data-consumers",
privileges=["SELECT"],
)
version: 1.1 # Required: "1.1" for DBR 17.2+
comment: "Description" # Optional: metric view description
source: catalog.schema.table # Required: source table/view
filter: column > value # Optional: global WHERE filter
dimensions: # Required: at least one
- name: Display Name # Backtick-quoted in queries
expr: sql_expression # Column ref or SQL transformation
comment: "Description" # Optional (v1.1+)
measures: # Required: at least one
- name: Display Name # Queried via MEASURE(`name`)
expr: AGG_FUNC(column) # Must be an aggregate expression
comment: "Description" # Optional (v1.1+)
joins: # Optional: star/snowflake schema
- name: dim_table
source: catalog.schema.dim_table
on: source.fk = dim_table.pk
materialization: # Optional (experimental)
schedule: every 6 hours
mode: relaxed
| Dimensions | Measures | |
|---|---|---|
| Purpose | Categorize and group data | Aggregate numeric values |
| Examples | Region, Date, Status | SUM(revenue), COUNT(orders) |
| In queries | Used in SELECT and GROUP BY | Wrapped in MEASURE() |
| SQL expressions | Any SQL expression | Must use aggregate functions |
| Feature | Standard Views | Metric Views |
|---|---|---|
| Aggregation locked at creation | Yes | No - flexible at query time |
| Safe re-aggregation of ratios | No | Yes |
| Star/snowflake schema joins | Manual | Declarative in YAML |
| Materialization | Separate MV needed | Built-in |
| AI/BI Genie integration | Limited | Native |
| Issue | Solution |
|---|---|
| SELECT * not supported | Must explicitly list dimensions and use MEASURE() for measures |
| "Cannot resolve column" | Dimension/measure names with spaces need backtick quoting |
| JOIN at query time fails | Joins must be in the YAML definition, not in the SELECT query |
| MEASURE() required | All measure references must be wrapped: MEASURE(\name`)` |
| DBR version error | Requires Runtime 17.2+ for YAML v1.1, or 16.4+ for v0.1 |
| Materialization not working | Requires serverless compute enabled; currently experimental |
Metric views work natively with:
Activates when the user asks about AI prompts, needs prompt templates, wants to search for prompts, or mentions prompts.chat. Use for discovering, retrieving, and improving prompts.
Search, retrieve, and install Agent Skills from the prompts.chat registry using MCP tools. Use when the user asks to find skills, browse skill catalogs, install a skill for Claude, or extend Claude's capabilities with reusable AI agent components.
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists' work to avoid copyright violations.