Schedule icon
Request icon
AllowFailure icon
SubmitRun icon
Query icon
IonToJson icon
If icon
SlackIncomingWebhook icon
Log icon

Databricks native dbt build with AllowFailure quarantine and Slack alerts

Orchestrate governed dbt builds on Databricks with structural error trapping, isolated telemetry parsing, and Slack notification integration.

Categories
CloudData

Data quality failures in dbt pipelines can prevent reliable data from reaching production. This blueprint combines a Databricks-native dbt job with Kestra orchestration to collect test results, identify failed tests, and notify the team through Slack.

How it works

  1. upload_to_uc_volume (io.kestra.plugin.core.http.Request) uploads a CSV directly to a Databricks Unity Catalog volume using the Files API.
  2. run_governed_dbt_build (io.kestra.plugin.databricks.job.SubmitRun) triggers a pre-created Databricks dbt job. This is wrapped in an allow_dbt_failure_trap (io.kestra.plugin.core.flow.AllowFailure) block. This block captures the error signal if a dbt test fails (which fails the Databricks job), preventing the flow from stopping so that the subsequent telemetry tasks can execute.
  3. fetch_dbt_test_telemetry (io.kestra.plugin.databricks.sql.Query) queries an audit table populated by a dbt on-run-end hook. It specifically looks for the invocation_id corresponding to the job run triggered in step 2 to parse results.
  4. evaluate_test_results (io.kestra.plugin.core.flow.If) evaluates the parsed JSON metric dataset. Splits flow routing paths dynamically based on structural error presence or missing data rows to notify Slack.

What you get

  • Write-Audit-Publish (WAP) Pattern: Bad data is stopped at the staging layer by dbt's DAG logic, while Kestra provides the visibility and alerting layer.
  • Governed Execution: By running dbt as a Databricks Job Task, the process inherits Unity Catalog permissions and cluster policies.
  • Resilient Orchestration: The flow captures the failure reason and communicates it to the team instead of failing silently.

Who it's for

Data Engineers using Databricks and dbt who want to move beyond simple pass/fail pipelines and implement robust data quality alerting without managing external containers.

Why orchestrate this with Kestra

Kestra bridges the gap between Databricks execution and external communication. While Databricks runs the heavy compute, Kestra handles the logic of what happens when things go wrong, integrating Slack notifications and conditional branching that are difficult to manage within a standard dbt-only environment.

Prerequisites

  • A Databricks workspace with Unity Catalog and a SQL warehouse.
  • A Git repo containing a dbt project with the on-run-end hook for telemetry.
  • A pre-configured Databricks Job with a dbt task.

Secrets

  • DATABRICKS_HOST: Your Databricks workspace URL.
  • DATABRICKS_TOKEN: A Personal Access Token.
  • DATABRICKS_HTTP_PATH: The HTTP path for your SQL Warehouse.
  • SLACK_WEBHOOK_URL: Your Slack application incoming webhook.

Quick start

  1. Add the dbt Macro: Add the save_test_results macro to your dbt project to enable telemetry.
  2. Configure the Flow: Update the dbt_job_id and volume_path inputs to match your environment.
  3. Run: Execute the flow; it will land data, trigger the build, and monitor the results.

How to extend

  • Post-Failure Cleanup: Add a task to delete the landing CSV if the dbt job fails.
  • Alternative Alerts: Replace the Slack task with Microsoft Teams or PagerDuty.
  • Data Freshness: Add a dbt source freshness check as an additional preceding task.

Outputs

  • total_tests: The total number of dbt test results found for the execution.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.