Skip to content

Commit 31881cc

Browse files
Apply suggestions from code review
Co-authored-by: Julia Crawford (Databricks) <julia.crawford@databricks.com>
1 parent c75e28d commit 31881cc

5 files changed

Lines changed: 24 additions & 25 deletions

File tree

knowledge_base/metric_view/README.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
# Unity Catalog Metric View
22

3-
This project demonstrates how to create a [Unity Catalog Metric View](https://docs.databricks.com/aws/en/metric-views/) using Databricks Asset Bundles. Once registered, the metric view becomes available to analysts and BI tools across your workspace, queryable via the `MEASURE()` SQL function.
3+
This project demonstrates how to create a [Unity Catalog Metric View](https://docs.databricks.com/aws/en/metric-views/) using Declarative Automation Bundles. Once registered, the metric view becomes available to analysts and BI tools across your workspace, queryable via the `MEASURE()` SQL function.
44

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

76
## Concrete example: Definition and Usage
87

9-
This project defines `bookings_kpis`, a metric view over the public sample dataset `samples.wanderbricks.bookings`.
8+
## `bookings_kpis` metric view
109

11-
### Metric View Definition
10+
This project defines `bookings_kpis`, a metric view over the public sample dataset `samples.wanderbricks.bookings`.
1211

1312
A SQL task in the job runs `CREATE OR REPLACE VIEW … WITH METRICS LANGUAGE YAML` from [`src/bookings_kpis.metric_view.sql`](src/bookings_kpis.metric_view.sql):
1413

@@ -60,7 +59,7 @@ The view integrates seamlessly with:
6059
### Prerequisites
6160

6261
* Databricks workspace with Unity Catalog enabled
63-
* A SQL warehouse on a runtime that supports Unity Catalog metric views (Public Preview; any recent serverless or PRO warehouse)
62+
* A SQL warehouse on a runtime that supports Unity Catalog metric views
6463
* Databricks CLI installed and configured
6564

6665
### Setup
@@ -84,14 +83,14 @@ databricks bundle run bookings_kpis_metric_view --target prod
8483

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

87-
## Advanced Topics
86+
### Notes
8887

89-
**Scheduling:** The job has a daily `periodic` trigger so the view definition is re-applied in production. [Development-mode](https://docs.databricks.com/dev-tools/bundles/deployment-modes.html) deploys pause the trigger automatically, so it only fires after `bundle deploy --target prod`.
88+
- The job has a daily `periodic` trigger so the view definition is re-applied in production. [Development-mode](https://docs.databricks.com/dev-tools/bundles/deployment-modes.html) pauses the trigger automatically, so it only fires after `bundle deploy --target prod`.
9089

91-
**Custom source table:** Point `source:` in the YAML body at any UC table you read from. The sample `samples.wanderbricks.bookings` is convenient for getting started; for production, use a curated table from your own pipeline.
90+
- Set `source:` in the YAML body to any UC table you read from. The sample `samples.wanderbricks.bookings` is convenient for getting started. For production, use a table from your own pipeline.
9291

9392
## Learn More
9493

95-
- [Unity Catalog Metric Views](https://docs.databricks.com/aws/en/metric-views/) — Official documentation
96-
- [Metric View YAML Reference](https://docs.databricks.com/aws/en/metric-views/yaml-ref)
97-
- [Databricks Asset Bundles](https://docs.databricks.com/dev-tools/bundles/index.html)
94+
- [Unity Catalog Metric Views](https://docs.databricks.com/metric-views/) — Official documentation
95+
- [Metric View YAML Reference](https://docs.databricks.com/metric-views/yaml-ref)
96+
- [Declarative Automation Bundles](https://docs.databricks.com/dev-tools/bundles/index.html)

knowledge_base/metric_view/databricks.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# This bundle shows how to create a Unity Catalog Metric View via a DABs job.
1+
# This example bundle defines a job that creates a Unity Catalog Metric View.
22
#
3-
# Metric Views are a Unity Catalog feature (Public Preview, Databricks Runtime 16.4+)
3+
# Metric Views are a Unity Catalog feature
44
# that let you declare reusable dimensions and measures over a base table, queryable
5-
# via the MEASURE() SQL function. DABs does not yet have a first-class resource type
6-
# for metric views, so this example uses a SQL task in a job to run
5+
# via the MEASURE() SQL function. Bundles do not yet support metric views as
6+
# a resource type, so this example uses a SQL task in a job to run
77
# `CREATE OR REPLACE VIEW ... WITH METRICS LANGUAGE YAML`.
88
#
99
# See also the dbt-based variant at ../metric_view-dbt.
1010
#
1111
# Docs:
12-
# https://docs.databricks.com/aws/en/metric-views/
13-
# https://docs.databricks.com/aws/en/metric-views/yaml-ref
12+
# https://docs.databricks.com/metric-views/
13+
# https://docs.databricks.com/metric-views/yaml-ref
1414

1515
bundle:
1616
name: metric_view
@@ -20,11 +20,11 @@ include:
2020

2121
variables:
2222
catalog:
23-
description: The Unity Catalog catalog where the metric view will be created
23+
description: The Unity Catalog where the metric view will be created
2424
schema:
2525
description: The schema where the metric view will be created
2626
warehouse_id:
27-
description: SQL warehouse ID used to run the CREATE VIEW statement. Find one via `databricks warehouses list`.
27+
description: SQL warehouse ID used to run the CREATE VIEW statement. To list available warehouses, use `databricks warehouses list`.
2828

2929
targets:
3030
dev:

knowledge_base/metric_view/resources/bookings_kpis.job.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resources:
55
description: Creates/refreshes the `bookings_kpis` Unity Catalog metric view.
66

77
trigger:
8-
# Re-apply the view definition daily. Dev-mode deploys pause this trigger;
8+
# Re-apply the view definition daily. Dev deployment mode pauses this trigger;
99
# in prod the job runs once per day. See https://docs.databricks.com/api/workspace/jobs/create#trigger
1010
periodic:
1111
interval: 1

knowledge_base/metric_view/src/bookings_kpis.metric_view.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Create (or replace) a Unity Catalog Metric View over samples.wanderbricks.bookings.
2-
-- See https://docs.databricks.com/aws/en/metric-views/yaml-ref for the YAML syntax.
2+
-- See https://docs.databricks.com/metric-views/yaml-ref for the YAML syntax.
33
--
44
-- Once deployed and run, query the metric view from any SQL editor with:
55
-- SELECT MEASURE(total_bookings), MEASURE(total_revenue)

knowledge_base/metric_view_dbt/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Unity Catalog Metric View using dbt
22

3-
This project demonstrates how to materialize a [Unity Catalog Metric View](https://docs.databricks.com/aws/en/metric-views/) via dbt-databricks using Databricks Asset Bundles. The metric view is defined as a dbt model with the [`metric_view` materialization](https://github.com/databricks/dbt-databricks/pull/1285) added in **dbt-databricks 1.12.0**.
3+
This project demonstrates how to materialize a [Unity Catalog Metric View](https://docs.databricks.com/metric-views/) via dbt-databricks using Declarative Automation Bundles. The metric view is defined as a dbt model with the [`metric_view` materialization](https://github.com/databricks/dbt-databricks/pull/1285) added in **dbt-databricks 1.12.0**.
44

55
**Learn more:** [Unity Catalog Metric Views](https://docs.databricks.com/aws/en/metric-views/) · SQL-job variant: [`../metric_view`](../metric_view)
66

@@ -93,7 +93,7 @@ The metric view will be created at `<catalog>.<your_username>.bookings_kpis` (de
9393

9494
## Learn More
9595

96-
- [Unity Catalog Metric Views](https://docs.databricks.com/aws/en/metric-views/) — Official documentation
97-
- [Metric View YAML Reference](https://docs.databricks.com/aws/en/metric-views/yaml-ref)
96+
- [Unity Catalog Metric Views](https://docs.databricks.com/metric-views/) — Official documentation
97+
- [Metric View YAML Reference](https://docs.databricks.com/metric-views/yaml-ref)
9898
- [`metric_view` materialization in dbt-databricks](https://github.com/databricks/dbt-databricks/pull/1285)
99-
- [Databricks Asset Bundles](https://docs.databricks.com/dev-tools/bundles/index.html)
99+
- [Declarative Automation Bundles](https://docs.databricks.com/dev-tools/bundles/index.html)

0 commit comments

Comments
 (0)