Webhook icon
Script icon
UploadFiles icon
Switch icon
Log icon
Fail icon
SlackIncomingWebhook icon

Find every model and dashboard a source column change would break

Column-level SQL impact analysis in Kestra with sqlglot. Find models and dashboards a source column change breaks, filters and joins included.

Categories
Data

"Can we drop this column?" is usually answered by searching the repository for its name, which misses aliases and misses every model downstream of a model that reads it. This flow builds column-level lineage across all SQL models with sqlglot and follows a proposed change downstream until nothing new is affected. It then checks the declared exposures (dashboards, exports) and returns one of three verdicts:

  • SAFE: nothing reads the column.
  • MODELS_TO_UPDATE: models must change in the same release, but no exposure breaks.
  • BREAKS_EXPOSURE: an exposure would break, so the change is blocked until its owner agrees.

Columns that never reach the output still matter. A column used only in a WHERE, JOIN, GROUP BY or HAVING breaks its model as a whole, and the flow tracks that, because output lineage alone misses it.

A demo project with four models and two exposures is inline. The analysis needs no secrets. An unknown column or a blocked change posts a Slack alert when notify_slack is true and SLACK_WEBHOOK_URL is set.

How it works

  1. analyze (io.kestra.plugin.scripts.python.Script, sqlglot==25.24.5):
    • fails when the column is not in sources.json, so a typo cannot read as SAFE,
    • orders the models so each is parsed after the models it reads, and registers each model's output columns in the schema,
    • for each output column, walks sqlglot.lineage back to its source columns,
    • records every column referenced inside a filter, join, group by or having clause,
    • walks downstream from the changed column, marking a whole model when a filter or join column it uses is affected,
    • matches the affected columns against exposures.json, writes impact.md and outputs the verdict.
  2. publish_impact (io.kestra.plugin.core.namespace.UploadFiles) writes schema-changes/<column>.md.
  3. decision (io.kestra.plugin.core.flow.Switch): SAFE logs, MODELS_TO_UPDATE logs the work at WARN, and BREAKS_EXPOSURE fails with the exposures and their owners.
  4. on_schema_change_request (io.kestra.plugin.core.trigger.Webhook) takes {"column": "raw.orders.amount"}.
  5. alert_flow_failure (errors) posts to Slack when a run fails and notify_slack is true, including a blocked change.

Quick start

column_change Verdict Why
raw.orders.amount BREAKS_EXPOSURE stg_orders.amount_usd, then fct_revenue.revenue, which the Revenue dashboard reads
raw.orders.status BREAKS_EXPOSURE Used only in stg_orders's WHERE, so stg_orders breaks, then fct_revenue and dim_customers, which join on it. 11 columns, both exposures
raw.customers.email MODELS_TO_UPDATE Only stg_customers.email reads it
raw.customers.signup_at SAFE Nothing reads it

The status row is why filter and join use is tracked: no output column comes from status, yet removing it breaks every model downstream.

Prerequisites

Secrets

  • SLACK_WEBHOOK_URL: failure alert from errors when notify_slack is true. Without it the alert task fails and the run still ends FAILED.

Inputs

  • column_change (SELECT): demo columns. Use the webhook body for any column.
  • dialect (STRING, default duckdb): any sqlglot dialect, such as snowflake, bigquery or postgres.

Using it with your project

  • Replace the inline files with a io.kestra.plugin.git.Clone of your models in a io.kestra.plugin.core.flow.WorkingDirectory.
  • Generate sources.json from your warehouse's information schema. sqlglot needs the source columns to resolve SELECT * and unqualified columns.
  • For dbt, compile first and parse target/compiled. Exposures can come from the dbt exposures: definitions.

Expected outputs

  • outputs.analyze.vars: verdict, affected_count, affected, models, filter_models, exposures.
  • Namespace file schema-changes/<column>.md.

Links

This blueprint was created by zkasuran.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.