Databricks DE · Topic 10.3
Turn queries into automation and visuals: schedule queries on Quartz cron, alert when a threshold trips, and build AI/BI dashboards with Genie authoring + subscriptions — all versionable as bundle code.
▸ condition: alert when orders_today = 0 (pipeline failure)
Mechanism: attach a schedule to a saved query; at each fire time it runs on a SQL Warehouse as the owner. Databricks uses 6-field Quartz cron (sec min hour day month dow), not 5-field Unix cron. Trade-off: cadence = freshness and cost.
# Quartz cron is 6 fields. "every day at 06:00": schedule: quartz_cron_schedule: "0 0 6 * * ?" # sec min hour day month dow timezone_id: America/New_York
Mechanism: an alert points at a query, defines an evaluation (a comparison on a result column vs a threshold), and on a schedule checks it — if met, sends to notification destinations. Trade-off: evaluates only when scheduled (cadence = detection lag); condition-only, not arbitrary logic.
-- The alert's backing query returns ONE row/column to compare. -- Condition (set in the alert): WHEN orders_today = 0 → notify on-call. SELECT count(*) AS orders_today FROM prod.sales.orders WHERE order_date = current_date();
Mechanism: the alert bundle resource (SQL alert v2) declares the query, evaluation, schedule, and warehouse — versioned and promoted by CI/CD. Trade-off: the bundle is the source of truth; UI edits get reverted on the next deploy.
# databricks.yml — verified keys (alert v2 resource) resources: alerts: orders_zero_alert: display_name: orders_zero_alert query_text: "SELECT count(*) AS orders_today FROM prod.sales.orders WHERE order_date = current_date()" evaluation: comparison_operator: EQUAL # EQUAL / GREATER_THAN / LESS_THAN … source: { name: orders_today } # result column to compare threshold: { value: { double_value: 0 } } schedule: quartz_cron_schedule: "0 0 6 * * ?" timezone_id: America/New_York warehouse_id: ${var.warehouse_id}
Mechanism: datasets (queries) feed the canvas; visualizations + parameters/filters cross-filter widgets; author by hand or with Genie (NL), then publish with scheduled refresh + email/Slack subscriptions. Trade-off: runs on a warehouse (cold-start latency); refresh runs as the publisher — mind permissions/cost. Successor to retired legacy/Redash dashboards.
-- A dashboard DATASET is a query, usually parameterized so filters work: SELECT region, sum(amount) AS revenue FROM prod.sales.orders WHERE order_date BETWEEN :start_date AND :end_date GROUP BY region ORDER BY revenue DESC;
.lvdash.jsonMechanism: an AI/BI Dashboard serializes to *.lvdash.json; the dashboard bundle resource references that file + a warehouse. databricks bundle generate dashboard exports an existing one. Trade-off: the JSON is generated — edit in the UI then re-export, don't hand-edit.
# databricks.yml — verified keys (dashboard resource) resources: dashboards: revenue_overview: display_name: "Revenue Overview" file_path: ../src/revenue_overview.lvdash.json warehouse_id: ${var.warehouse_id} # export an existing dashboard, then deploy: # databricks bundle generate dashboard --existing-path "/Workspace/.../Revenue Overview" # databricks bundle deploy -t prod
= 0, > threshold); when met, sends to notification destinations (email/Slack/webhook). Fires only when the schedule runs.0 6 * * *) — Databricks wants 6-field Quartz (0 0 6 * * ?)..lvdash.json instead of editing in the UI and re-running bundle generate dashboard.