Altimate MCP

Plan And Execute A PySpark To dbt Migration With Codebase Context

Altimate MCP reads PySpark entry points, validation modules, and transformations, plans a phased dbt migration, and remembers the goals for next sprint.

Plan and execute a PySpark to dbt migration with codebase context
TL;DR
  • Pain. Migrating a sprawling PySpark codebase to dbt spans sprints and dozens of modules, complex enough that teams default to a services engagement rather than risk losing track of what's already converted.
  • Who it is for. Platform leads and analytics engineers migrating PySpark to dbt on Databricks.
  • What it is. Altimate MCP reads the PySpark codebase, plans a phased migration to dbt, and stores the plan in the Memory Hub so the next sprint picks up where this one left off.

The Migration That The Services Firm Priced As Six Figures

A retail-analytics platform lead has a Databricks-based PySpark project that powers e-commerce reporting. Twelve transformation modules across revenue, customer, product, and time-series analytics. A profiles.yml for the target warehouse already exists. The migration to dbt is on the roadmap, the services firm's quote is six figures, the timeline is two quarters. The lead's internal answer would normally be: pay the firm, get the migration, lose the institutional knowledge. The right answer is to keep the work in-house with an agent that reads the codebase, plans the phases, and remembers the goals next sprint.

The PySpark-to-dbt walkthrough at migrate PySpark to dbt with Altimate MCP is that path. Altimate reads the project; the team writes the migration.

Codebase Understanding Before The First Line Of dbt

The walkthrough's first phase is not generation; it is reading. The agent analyses the existing PySpark project before proposing any dbt:

What the agent readsWhat it extracts
main.py (entry points)run order, which modules fire under which jobs
readers/ (data readers)source tables, file paths, read patterns
validation/ (data quality modules)the team's data-quality checks
transformations/revenue.py etc.the actual business logic per domain
profiles.ymlthe target Databricks warehouse setup
Memory Hubprior decisions on this migration

The agent reports back what it found in plain English. The engineer reviews. Only after the engineer confirms the project structure does the agent move to the planning phase. The migration is not a guess; the agent has read the code.

A legacy estate of SSIS packages, Informatica mappings, stored procedures, PySpark jobs, and Talend workflows on the left, translated through schema_migration, sql_translate, and dbt_unit_test_gen into a dbt model grid on the right where every model carries docs, tests, and lineage.

The team's migration guide lives in the Knowledge Hub as a shareable document, so the same rules apply whether the agent or a person picks up the work:

Altimate Knowledge Hub showing a "pyspark dbt migration" guide document, a shareable dynamic URL, and the guide's key-benefits summary: 90% faster batch processing, a 5x increase in bug identification, and a 70% reduction in software licensing fees.

In the IDE, the engineer attaches that guide as a doc reference and asks the agent to migrate the project. This is where the request starts, in plain language, with the team's own conventions already in scope:

Cursor with the PySpark-based Obsidian Ecommerce Analytics project open, attaching the pyspark-dbt-migration Knowledge Hub guide as a doc reference before asking the agent to migrate the Databricks reporting project to dbt.

Before writing anything, the agent checks memory for what it already knows about this project, so it does not start from zero every session:

Agent calling the search_memory MCP tool with the query "ecommerce reporting project pyspark databricks migration dbt" and returning stored context about the user's Databricks instance and cluster configuration before starting the migration.

The result: a new dbt model with its schema and tests, plus a migration guide documenting exactly what changed, ready for the engineer to test:

Agent having generated a new dbt model (assert_revenue_consistency.sql) and a _models.yml schema file with tests, then producing a MIGRATION_GUIDE.md documenting the architecture changes, with a confirmation that the migration is ready to be tested.

The Knowledge Hub Artifact Carries The Team's Migration Rules

The Knowledge Hub artifact (forked from the Altimate "PySpark dbt migration" template or written by the team) carries the rules the agent applies to the plan:

Rule the artifact carriesWhat it changes about the plan
Layering convention (stg_int_mart_)every migrated module fits the convention
Test requirements per layerthe agent generates the right tests at each layer
When to migrate vs when to keep PySparkthe agent flags modules that are not good migration candidates
Naming conventions per domainthe agent uses the team's preferred names
Performance expectationsthe agent budgets the warehouse cost per phase

The artifact has a stable URL the engineer references in the prompt; the agent reads it as part of the context. The companion Knowledge Hub article covers the multimodal upgrade where the artifact can include diagrams (an architecture diagram showing the target layout, for instance) that the answer cites alongside text.

The Plan And The Per-Phase Execution

The agent proposes a phased plan based on the codebase reading. The realistic shape of the walkthrough's plan:

PhaseScopeOutput
Phase 1data readers (readers/) + validation modules (validation/)dbt sources + staging models with the original data-quality checks restated as dbt tests
Phase 2revenue, customer, product transformationsintermediate dbt models with the business logic preserved
Phase 3time-series analyticsmart-layer dbt models with the time-series grain enforced
Phase 4the orchestration glue (the equivalent of main.py)a dbt-native job graph, executed by the team's orchestrator (Airflow, Dagster, dbt Cloud)

For each phase, the agent generates the dbt SQL plus the YAML, runs compile_model to confirm the model parses, runs databricks_execute_sql against the Databricks SQL warehouse to verify the output rows match the PySpark output (using the parity-check pattern from the companion warehouse migration article). The engineer reviews, signs off, and the agent moves to the next phase. One phase at a time; verification at each step; nothing ships without a row-count match.

The Memory Hub Is What Makes The Migration Survive A Sprint Break

A migration that pauses for a holiday or a feature freeze is a migration that forgets where it was. The Memory Hub fixes that. From the walkthrough:

The Altimate MCP intelligently searches for relevant previous memories to reduce hallucinations or rework, demonstrating its understanding of your entire tech stack, coding styles, and architectural choices.

The Memory Hub stores:

What goes inWhat the next sprint reads back
The phased plan and the team's sign-offwhich phase to pick up next
The conventions decided in phase 1so phase 2 stays consistent
The modules already convertedso phase 3 does not re-do work
The patterns that worked (and the ones that did not)so the next module's generation skips the dead ends

Cross-team Memory Hub sharing makes the same context available across team members. A second engineer joining the migration in week 4 picks up the agent in the IDE, the Memory Hub fills in the context, the work continues. The migration is not in someone's head; it is in the Memory Hub.

Twelve Databricks Tools, With Notebook Export As The Hidden One

Altimate calls 12 Databricks tools, documented in the Databricks integration guide. The two that matter most for migration:

  • databricks_export_notebook with format options SOURCE, HTML, JUPYTER, DBC. Useful when the PySpark logic lives inside Databricks notebooks rather than a .py repo. The agent exports the notebook in SOURCE form, reads the code, generates the dbt equivalent.
  • databricks_execute_sql with warehouse_id. Runs the SQL of the new dbt model against the Databricks SQL warehouse to verify the output rows match the PySpark output.

The companion article on the Altimate Code warehouse migration story covers the dialect-translation side; this agent-driven flow extends the same pattern with the codebase-context and Memory Hub layers that a long-running migration needs. The companion PowerUser Plugin for dbt translateSQL article covers the editor-side translation tool that handles individual files.

What The Agent Makes Possible That The Services Firm Did Not

The agent turns a six-figure outsourced migration into a phased, team-driven project. The codebase-reading step gives an honest project plan up front; the Knowledge Hub artifact keeps the team's conventions enforced; the Memory Hub keeps the context across sprints; the Databricks integration verifies parity per phase. The companion articles on the warehouse migration story, editor-side dialect translation, and the sprint-work agent cover the layers around it. The migration is the team's; the agent is the workbench.

Wire Altimate MCP into your AI client

Frequently Asked Questions