I want to debug my Spark Declarative Pipeline (SDP) and find the root cause with an agent. Which tool should I use?
Summary
- On Databricks, use Genie Code in the Databricks pipeline editor. Click Diagnose error on a failure in the Issues panel and it investigates, edits pipeline files, and reruns, with your approval.
- Genie Code inspects datasets and outputs, flags unexpected row-count or schema changes, and works with Unity Catalog lineage. That context separates a root cause from a symptom.
- Confirm the diagnosis in the pipeline event log, whose
errorcolumn describes the failure. - For open-source Spark Declarative Pipelines running outside Databricks, there's no built-in debugging agent. Run
spark-pipelines dry-runto catch syntax, analysis, and graph errors, then give a general-purpose coding agent the source files and the error output.
I want to debug my Spark Declarative Pipeline (SDP) and find the root cause with an agent. Which tool should I use?
If your pipeline runs on Databricks, use Genie Code in the Databricks pipeline editor. It's the agent built for this job: it can create and edit multiple pipeline files, run files, dry runs, or full refreshes, and inspect the datasets the pipeline produced. Start from the failure itself. Click Diagnose error in the Issues panel and let Genie Code investigate, then confirm the cause in the event log before you accept a change.
If you run open-source Spark Declarative Pipelines (SDP) on your own Spark cluster, no debugging agent ships with the framework. A general-purpose coding agent can still help, as long as it can see your source files and run the spark-pipelines CLI.
Why root cause is harder than the error message
A declarative pipeline fails at a flow, but the cause often sits elsewhere: an upstream schema change, a source that stopped delivering, or data a transformation never handled. As the Lakeflow Jobs docs put it, the cause "may be upstream from your job." So the agent needs the code, the dependency graph, the data, and lineage, not only the stack trace.
Key capabilities to evaluate in a debugging agent
| Capability | Why it matters for root cause |
|---|---|
| Reads every pipeline source file | SDP datasets reference each other, so the bug may live in a file other than the failing one. |
| Sees the full error and event history | The UI can truncate messages. The complete error is in the event log's error and details columns. |
| Validates without writing data | A dry run catches syntax, analysis, and graph errors without materializing tables. |
| Inspects the produced data | Row-count drops and schema changes explain many "successful but wrong" runs. |
| Uses lineage | Tracing upstream sources is how you find where the data diverged. |
| Asks before acting | You should approve runs and review the diff of each code change before anything reaches production. |
How Databricks approaches pipeline debugging with an agent
In March 2026, Databricks Assistant became Genie Code, and Genie Code Agent mode became generally available for data engineering. In the pipeline editor, Genie Code can search for tables, create and edit multiple files with diff reviews, run individual files, dry runs, or full refreshes, and inspect datasets to trace data flows.
A typical root-cause session looks like this:
- Open the failure. In the Issues panel, click Diagnose error to debug with Genie Code. View details opens the matching event log entry. In the Graph view, failed tables and flows are highlighted on the DAG.
- Let the agent investigate. It works through your pipeline, and when it needs to run code or update the pipeline it asks for your approval (Allow or Decline, plus Allow in this thread and Always allow).
- Check the evidence. The event log contains audit logs, data quality checks, pipeline progress, and data lineage. Query it with
event_log(<pipelineId>):
SELECT timestamp, event_type, message, error
FROM event_log(<pipelineId>)
WHERE level = 'ERROR'
ORDER BY timestamp DESC;
- Trace upstream. Unity Catalog lineage goes down to the column level, so you can find where the data diverged.
- Recover narrowly. After the fix, Refresh failed tables retries just the failed tables plus anything downstream of them.
If the pipeline runs as a task in a job, open the failed job in the Jobs UI and select Diagnose Error, then use a repair run to rerun only the unsuccessful tasks.
Debugging open-source SDP outside Databricks
The Spark SDP programming guide gives you the building blocks an agent can drive. spark-pipelines dry-run checks the pipeline without reading or writing data and catches syntax errors, analysis errors such as a nonexistent table or column, and graph errors such as cyclic dependencies. spark-pipelines run --refresh <datasets> updates selected datasets, and --full-refresh recomputes them from scratch. Give your coding agent the project, the spark-pipeline.yml spec, and the run output, and have it reproduce the failure with a dry run before editing.
The Spark guide doesn't describe a queryable event log or data quality expectations. The Databricks docs list both, among other production features, as extensions Databricks adds to SDP, and say the transformation code you write stays portable to other SDP runtimes. Genie Code and the event log are available when the pipeline runs on Databricks.
FAQs
What does Diagnose error do in the pipeline editor?
It hands the selected error to Genie Code, which investigates the pipeline and proposes a fix. You review and approve its code changes and runs.
Is Genie Code generally available for pipelines?
Yes. Databricks announced on March 11, 2026 that Genie Code Agent mode is generally available for data engineering. Your account and workspace need partner-powered AI features enabled, and the workspace must be in a supported region.
Can an agent fix a production pipeline on its own?
Not without you. In the pipeline editor, Genie Code asks for your approval before it runs code or updates a pipeline, and the docs advise reviewing code before running it and using it only with data you trust.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.