Skip to content

Knowledge base: metric views#156

Open
lennartkats-db wants to merge 6 commits into
mainfrom
lennart.kats/knowledge-base-metric-views
Open

Knowledge base: metric views#156
lennartkats-db wants to merge 6 commits into
mainfrom
lennart.kats/knowledge-base-metric-views

Conversation

@lennartkats-db
Copy link
Copy Markdown
Contributor

Adds metric view examples to knowledge base: one based on a SQL job, one based on databricks-dbt.

Two parallel knowledge_base demos for creating a Unity Catalog Metric View
from a bundle:

- knowledge_base/metric_view/ — minimal sql_task-in-a-job pattern that runs
  CREATE OR REPLACE VIEW ... WITH METRICS LANGUAGE YAML against a SQL
  warehouse.
- knowledge_base/metric_view-dbt/ — dbt-databricks 1.12.0+ variant using the
  new `metric_view` materialization (dbt-databricks PR #1285).

Both define bookings_kpis over samples.wanderbricks.bookings and were
verified end-to-end on a real workspace (17,948 bookings / $9.9M revenue).

Co-authored-by: Isaac
From a fresh-user walkthrough of both metric_view examples:

- Add `CREATE SCHEMA IF NOT EXISTS` to the SQL variant so the example works
  even when the target schema doesn't pre-exist (the dbt variant already
  handles this via the adapter).
- Mention the `host: https://company.databricks.com` placeholder in both
  READMEs' Getting started — previously a silent first-time-user trap.
- Note that the default `catalog: main` is often not writable; flag this in
  the Getting started for both variants.
- Align the YAML body with the official docs:
    - bump version 0.1 → 1.0
    - drop the redundant `status` dimension (the filter already pins it)
    - drop outer quotes on `filter:`
    - add `comment:` at the metric view level and on each measure
- Soften the DBR / wrapper-internals claims in both READMEs to match
  what the docs actually guarantee.
- Drop the misleading "serverless" qualifier on the warehouse placeholder.

Co-authored-by: Isaac
- Both jobs gain a `trigger: periodic: {interval: 1, unit: DAYS}` so the
  view definition is re-applied daily in production. mode: development
  auto-pauses the trigger; only fires after `bundle deploy --target prod`.
- Restructure both READMEs to match the udtf-operator shape:
  Concrete Example (Definition + SQL Usage), Getting Started
  (Prerequisites / Setup / Deployment for dev and prod), Advanced Topics,
  Learn More.
- Link Advanced Topics' scheduling note to the deployment-modes docs.

Co-authored-by: Isaac
@lennartkats-db lennartkats-db changed the title [DRAFT] Knowledge base: metric views Knowledge base: metric views May 28, 2026
Comment thread knowledge_base/metric_view/resources/bookings_kpis.job.yml Outdated
Comment thread knowledge_base/metric_view/databricks.yml Outdated
Comment thread knowledge_base/metric_view/databricks.yml Outdated
Comment thread knowledge_base/metric_view/databricks.yml Outdated
Comment on lines +33 to +34
workspace:
host: https://company.databricks.com
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would take workspace out completely from the example

Comment thread knowledge_base/metric_view/README.md Outdated
Comment thread knowledge_base/metric_view/src/bookings_kpis.metric_view.sql Outdated
Comment thread knowledge_base/metric_view/databricks.yml Outdated
Comment thread knowledge_base/metric_view/databricks.yml Outdated
Comment thread knowledge_base/metric_view/databricks.yml Outdated
Comment thread knowledge_base/metric_view/README.md Outdated
- Databricks SQL dashboards / AI/BI Genie
- Any BI tool that connects to your workspace

## Getting Started With This Project
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Getting Started With This Project
## Get started

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually is all of this Get started? Seems like it's just Usage?

Comment thread knowledge_base/metric_view/README.md Outdated
Comment thread knowledge_base/metric_view/README.md Outdated
Comment thread knowledge_base/metric_view/README.md Outdated
Comment thread knowledge_base/metric_view/README.md Outdated

**Learn more:** [Unity Catalog Metric Views](https://docs.databricks.com/aws/en/metric-views/) · dbt-based variant: [`../metric_view_dbt`](../metric_view_dbt)

## Concrete example: Definition and Usage
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Concrete example: Definition and Usage

This is a little weird - I'd probably get rid of this, and just make the edit i suggest below so there is one section that describe the metric view.

Comment thread knowledge_base/metric_view/README.md Outdated

`{{catalog}}` and `{{schema}}` in the SQL file are substituted from job parameters at run time.

### SQL Usage
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### SQL Usage

Seems unnecessary since it is still describing the metric view

Comment thread knowledge_base/metric_view/README.md Outdated
Comment thread knowledge_base/metric_view/README.md Outdated
Comment thread knowledge_base/metric_view_dbt/README.md Outdated
Comment thread knowledge_base/metric_view_dbt/README.md Outdated
Comment thread knowledge_base/metric_view_dbt/README.md Outdated

The metric view will be created at `<catalog>.<your_username>.bookings_kpis` (dev) or `<catalog>.default.bookings_kpis` (prod).

## Advanced Topics
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as in the other README.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comments as the other README.md above

Co-authored-by: Julia Crawford (Databricks) <julia.crawford@databricks.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants