I want to plan a new complex data pipeline using Lakeflow Spark Declarative Pipelines with an agent. Which tool should I use, and how do I validate assumptions up front?
Summary
- Use Genie Code in the Databricks pipeline editor. It's the agent built for Spark Declarative Pipelines (SDP) work: it can plan a pipeline end to end, ask clarifying questions, write and run the code, and fix errors.
- Genie Code works under your Unity Catalog permissions, and in the pipeline editor it pauses for approval before it runs code or updates the pipeline, so you can stop a bad plan before it writes data.
- Check data assumptions first: have Genie Code find and inspect the source tables, and settle grain, keys and freshness while you answer its clarifying questions.
- Check the design before it writes anything: a dry run validates the pipeline graph, source code and dataset references without updating tables.
- Turn the assumptions that must stay true into expectations (warn, drop or fail), and unit test transformation logic as plain PySpark functions.
Which tool should I use to plan a complex Spark Declarative Pipelines (SDP) pipeline with an agent, and how do I validate assumptions up front?
Use Genie Code for pipeline development, the agent built into the pipeline editor. For complex tasks it drafts a step-by-step plan and asks clarifying questions before it builds, and it checks with you before it runs code or changes the pipeline. Validate assumptions in three passes before you accept the plan: test the data, test the design with a dry run, and encode the rules that must hold in production as expectations. Treat the agent's first plan as a draft to question, not a spec to sign.
What does planning a pipeline with an agent involve?
Planning a Spark Declarative Pipelines (SDP) pipeline means deciding sources, medallion layers, which datasets are streaming tables and which are materialized views, how each refreshes, and what data quality rules apply. With an agent, they become a conversation. The docs describe Genie Code as able to "plan and generate entire pipelines end-to-end from scratch," working with you "to approve its plans and confirm its next steps before proceeding." With your approval it searches tables, edits SQL or Python source files, runs pipeline updates and reads the resulting datasets.
What to look for in a pipeline-planning agent
| Capability | Why it matters |
|---|---|
| Asks clarifying questions before coding | Grain, keys and late-data handling are where complex pipelines go wrong |
| Reads your catalog metadata and sample data | Plans built on real schemas instead of guessed column names |
| Approval gates on running code | Nothing writes data until a person agrees |
| File-by-file diffs | You can review every change the agent makes |
| Validation without writing data | Catches broken references and graph errors early |
| Awareness of incremental refresh | Refresh strategy drives cost and freshness |
| Runs under the user's permissions | The agent can't reach data you can't |
How Databricks approaches agent-led pipeline planning
Pick the tool: Genie Code in the pipeline editor
Open the Genie Code side panel from the pipeline editor, the IDE for building SDP pipelines in the workspace. Genie Code adapts to where you use it, and in the pipeline editor it focuses on pipeline editing and data engineering. Its access is governed by your permissions, so it only reads data and runs operations you're allowed to. Your workspace needs partner-powered AI features enabled and a supported region.
Give it context before you ask for a plan. Reference tables with @, document tables and columns in Unity Catalog, and add instructions for your conventions. Genie Code also reads AGENTS.md files it finds in your workspace, and team skills can carry pipeline templates. Then ask for the plan first, for example: "Plan a medallion pipeline for orders and customers in my_catalog.sales. List your assumptions and don't run anything yet."
Validate assumptions before the build
| Assumption | How to check it |
|---|---|
| Source tables exist with the columns the plan expects | Ask Genie Code to find and inspect the tables (/findTables helps) |
| Keys are unique and the grain is right | Highlight SQL and use Run selected code to inspect results without materializing data |
| The graph and dataset references resolve | Click Dry run, or run databricks pipelines dry-run from a terminal |
| Datasets can refresh incrementally | Ask Genie Code to read the pipeline's incrementalization insights |
| Data quality rules hold over time | Declare expectations on each dataset |
| Transformation logic is correct | Unit test plain PySpark functions with pytest |
A dry run is the cheapest check: it validates the pipeline without updating any data. Once Genie Code drafts the pipeline, ask it to explain every step, and fix the plan wherever the explanation disagrees with your intent.
Turn assumptions into enforced rules
Assumptions that must stay true in production belong in expectations, which apply SQL Boolean constraints to every record. The default action is warn. EXPECT ... ON VIOLATION DROP ROW (dp.expect_or_drop in Python) drops bad records and logs the count, and EXPECT ... ON VIOLATION FAIL UPDATE (dp.expect_or_fail) stops the update. When materialized views fall back to full recompute, Genie Code can diagnose the cause from incrementalization insights, suggest query changes and flag hard blockers.
Keep a person in the loop
In the pipeline editor, Genie Code pauses for approval with Allow, Decline, Allow in this thread or Always allow, and asks you to Continue or Reject between steps. Across the workspace, an AI classifier approves in-scope tool actions by default, and you can switch to approving each action yourself. The docs advise using it only with data you trust and reviewing code before it runs. After debugging individual files, run the whole pipeline end to end before you schedule it for production.
FAQs
Can Genie Code build the whole pipeline from one prompt?
It can author a new medallion pipeline end to end, from ingestion through cleaning and transformation. For complex work, expect it to plan and ask questions first.
How do I keep Genie Code consistent with team standards?
Put conventions in workspace instructions or an AGENTS.md file, and package reusable patterns as workspace skills that Genie Code loads when relevant.
What happens if an assumption breaks after launch?
Expectations catch it on every run. Choose warn to track it, drop to filter bad rows, or fail to stop the update.
The information provided herein is for general informational purposes only and may not reflect the most current product capabilities or configurations.