Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .test/skills/databricks-metric-views/ground_truth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test_cases:
outputs:
response: "Here's a metric view for order analytics:\n\n```sql\nCREATE OR REPLACE\
\ VIEW catalog.schema.orders_metrics\nWITH METRICS\nLANGUAGE YAML\nAS $$\n \
\ version: 1.1\n comment: \"Orders KPIs for sales analysis\"\n source: catalog.schema.orders\n\
\ version: 1.1\n source: catalog.schema.orders\n comment: \"Orders KPIs for sales analysis\"\n\
\ filter: order_date > '2020-01-01'\n dimensions:\n - name: Order Month\n\
\ expr: DATE_TRUNC('MONTH', order_date)\n comment: \"Month of order\"\
\n - name: Order Status\n expr: CASE\n WHEN status = 'O' THEN\
Expand Down Expand Up @@ -179,8 +179,8 @@ test_cases:
prompt: Show me the full YAML specification for a metric view definition
outputs:
response: "```yaml\nversion: 1.1 # Required: \"1.1\" for DBR\
\ 17.2+\ncomment: \"Description\" # Optional\nsource: catalog.schema.table\
\ # Required: source table/view\nfilter: column > value # Optional:\
\ 17.2+\nsource: catalog.schema.table # Required: source table/view\ncomment:\
\ \"Description\" # Optional: metric view description\nfilter: column > value # Optional:\
\ global WHERE filter\n\ndimensions: # Required: at least\
\ one\n - name: Display Name\n expr: sql_expression\n comment: \"Description\"\
\n\nmeasures: # Required: at least one\n - name: Display\
Expand Down Expand Up @@ -825,8 +825,8 @@ test_cases:
LANGUAGE YAML
AS $$
version: 1.1
comment: "Customer support ticket KPIs"
source: catalog.schema.support_tickets
comment: "Customer support ticket KPIs"
filter: created_at >= '2024-01-01'

dimensions:
Expand Down Expand Up @@ -1058,8 +1058,8 @@ test_cases:
LANGUAGE YAML
AS $$
version: 1.1
comment: "Transaction metrics - migrated from standard view"
source: catalog.schema.transactions
comment: "Transaction metrics - migrated from standard view"

dimensions:
- name: Region
Expand Down Expand Up @@ -1226,8 +1226,8 @@ test_cases:
LANGUAGE YAML
AS $$
version: 1.1
comment: "Product usage KPIs: DAU and feature adoption"
source: catalog.schema.product_usage
comment: "Product usage KPIs: DAU and feature adoption"

dimensions:
- name: Date
Expand Down
4 changes: 2 additions & 2 deletions databricks-skills/databricks-metric-views/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
comment: "Orders KPIs for sales analysis"
source: catalog.schema.orders
comment: "Orders KPIs for sales analysis"
filter: order_date > '2020-01-01'
dimensions:
- name: Order Month
Expand Down Expand Up @@ -167,8 +167,8 @@ manage_metric_views(

```yaml
version: 1.1 # Required: "1.1" for DBR 17.2+
comment: "Description" # Optional: metric view description
source: catalog.schema.table # Required: source table/view
comment: "Description" # Optional: metric view description
filter: column > value # Optional: global WHERE filter

dimensions: # Required: at least one
Expand Down
8 changes: 4 additions & 4 deletions databricks-skills/databricks-metric-views/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
comment: "Product sales metrics"
source: catalog.schema.sales
comment: "Product sales metrics"
dimensions:
- name: Product Name
expr: product_name
Expand Down Expand Up @@ -98,8 +98,8 @@ WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
comment: "Efficiency and per-unit metrics"
source: catalog.schema.transactions
comment: "Efficiency and per-unit metrics"
dimensions:
- name: Department
expr: department_name
Expand Down Expand Up @@ -176,8 +176,8 @@ WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
comment: "Sales analytics with customer and product dimensions"
source: catalog.schema.fact_sales
comment: "Sales analytics with customer and product dimensions"

joins:
- name: customer
Expand Down Expand Up @@ -329,8 +329,8 @@ WITH METRICS
LANGUAGE YAML
AS $$
version: 1.1
comment: "TPC-H Orders KPIs - demo metric view"
source: samples.tpch.orders
comment: "TPC-H Orders KPIs - demo metric view"
filter: o_orderdate > '1990-01-01'

dimensions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def _build_yaml_block(
"""
lines = [f"version: {version}"]

lines.append(f"source: {source}")

if comment:
lines.append(f'comment: "{comment}"')

lines.append(f"source: {source}")

if filter_expr:
lines.append(f"filter: {filter_expr}")

Expand Down