Flow icon
Webhook icon
Schedule icon
Get icon
WorkingDirectory icon
Clone icon
DbtCLI icon
Docker icon
Script icon
Query icon
OutputValues icon
If icon
Request icon
Loop icon
Parallel icon
Log icon
Set icon
SlackIncomingWebhook icon
AIAgent icon
GoogleGemini icon
Fail icon

Gate Apache Superset Dataset Sync and Cache Warming on dbt Builds and DuckDB Reconciliation

Build dbt marts on DuckDB, enforce KV baseline volume and metric gates, and sync/warm Apache Superset dashboards via HTTP or triage failures with Gemini.

Categories
AIData

A green dbt build or a basic unique and not_null suite does not guarantee dashboards are safe to refresh. Partial loads or sign-inversion bugs pass key tests and pollute cached BI charts. This blueprint gates Apache Superset schema sync and cache warming on a dbt Core build and a stateful DuckDB reconciliation check against Kestra's KV Store, with zero-secret dry-run defaults.

How it works

  1. Triggers: Runs via on_upstream_ingestion_completed (Flow), inbound_elt_webhook (Webhook), or morning_bi_refresh_schedule (Schedule, 0 6 * * 1-5 UTC, disabled: true).
  2. KV Baseline: load_previous_mart_baseline (kv.Get) reads the last certified row count and metric sum for inputs.mart_table.
  3. dbt Build (WorkingDirectory): Clones inputs.dbt_repository_url (git.Clone), runs dbt build --select +exposure:* (DbtCLI), and extracts exposures from manifest.json while exporting inputs.mart_table to mart_snapshot.parquet (python.Script).
  4. DuckDB Gate: audit_mart_volume_and_reconciliation (duckdb.Query) checks key integrity, positive metrics, and row volume within max_volume_drop_pct of the KV baseline. publish_execution_metrics (OutputValues) exposes {{ outputs.publish_execution_metrics.values.contract_verdict }}.
  5. Superset Sync (If + Loop + Parallel): On pass, logs into /api/v1/security/login (http.Request), calls PUT /api/v1/dataset/{id}/refresh and PUT /api/v1/chart/warm_up_cache per exposure, and updates the KV baseline (kv.Set). On breach, runs optional Gemini triage (AIAgent) and fails at halt_on_quarantine.

What you get

  • Lineage-driven Superset dataset sync and chart cache warming from dbt exposures.
  • Parameterized DuckDB reconciliation (mart_table, primary_key_column, metric_column) backed by Kestra KV state.
  • Fault drills (DROP_90_PCT_VOLUME, INJECT_NEGATIVE_REVENUE, BREAK_PRIMARY_KEY_UNIQUENESS) and dry-run defaults.

Who it's for

  • Analytics Engineers managing dbt marts and exposures backing Apache Superset dashboards.
  • Data Platform Teams enforcing Write-Audit-Publish (WAP) gates before BI cache refreshes.

Why orchestrate this with Kestra

dbt compiles SQL and Superset caches charts, but neither tracks cross-run baselines or gates API fan-out on SQL checks. Kestra coordinates workspace files, KV state, Loop + Parallel HTTP retries, and Gemini AI triage in one YAML flow.

Prerequisites

  • A Kestra worker with Docker enabled for io.kestra.plugin.dbt.cli.DbtCLI.
  • No secrets are needed for default dry-run runs (superset_dry_run: true, notify_slack: false, enable_ai_triage: false).

Secrets

  • WEBHOOK_KEY: Secret key for inbound_elt_webhook.
  • SUPERSET_USERNAME and SUPERSET_PASSWORD: Superset credentials (when superset_dry_run: false).
  • SLACK_WEBHOOK_URL: Slack webhook URL (when notify_slack: true).
  • GEMINI_API_KEY: Google Gemini API key (when enable_ai_triage: true).

Quick start

  1. Import into company.analytics and click Execute with default inputs (superset_dry_run: true, fault_injection_mode: NONE) to build kestra-io/dbt-demo and save the KV baseline.
  2. Re-run with fault_injection_mode: DROP_90_PCT_VOLUME to see DuckDB block the Superset refresh and fail at halt_on_quarantine.
  3. Point inputs at your dbt repo and Superset URL, add secrets, set superset_dry_run: false, and enable morning_bi_refresh_schedule.

How to extend

  • Swap ghcr.io/kestra-io/dbt-duckdb:latest for dbt-postgres, dbt-snowflake, or dbt-bigquery.
  • Chain io.kestra.plugin.datahub.Ingestion after save_certified_baseline to push manifest.json lineage to DataHub.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.