BigQuery to Databricks migration
In 2022 I led the data warehouse migration from BigQuery to Databricks at an education provider with around 400 employees. Afterwards we switched BigQuery off. Storage, processing, code and reporting sat on one platform.
- BigQuery in Google Cloud · processing in AWS
- Databricks on AWS · Delta Lake, PySpark and dbt
- BigQuery switched off · one platform
The project at a glance
- Role
- Project lead and hands-on engineering
- Period
- Second and third quarter of 2022
- Setting
- Education provider with around 400 employees and around 1,000 students
- Stack
- BigQuery, Databricks on AWS, Delta Lake, dbt, PySpark, SQL, Snowplow
- Result
- BigQuery switched off. About two years later Databricks replaced Tableau as well.
Project overview and my role
I owned the migration from planning through to switching BigQuery off. I set the roadmap, built and prioritized the portfolio of data products, and defined the data quality checks and the minimum levels for freshness and availability. I made most decisions myself. For the larger ones I prepared decision papers and presented them to the management team.
I shared the implementation with the team. I worked hands-on on dbt models, PySpark jobs, SQL, deployment and resource configuration.
Starting point and why I chose Databricks
BigQuery was our only service in Google Cloud. The rest of our infrastructure ran in AWS. Automations and admin workflows lived in Retool with its own databases. Each tool had its own access, its own roles and individual people who knew their way around it.
BigQuery charged by the amount of data scanned. Every new query and every new model was therefore a cost risk. Before a new process went live, we checked how much data it read, and we added partition filters and intermediate tables to keep scans small. That slowed development down and made the code more complicated than the business logic required.
I evaluated Databricks against three requirements. The platform had to fit our AWS environment, replace as many of the existing tools as possible, and let us control cost through compute resources instead of through each individual query. Databricks ran in AWS. Storage, processing, schedules, permissions and dashboards sat there in one place. Cost depended on clusters whose size and runtime we set ourselves.
Data flow before and after the migration
Simplified view.
Before
- Application databases, data feeds and Retool workflows
- ETL processing in AWS
- BigQuery in Google Cloud
- Tableau
After
- Application databases, data feeds, Snowplow events and Retool inputs
- Raw data as Delta tables in Databricks on AWS
- Transformation and automation with PySpark and dbt in Databricks
- Databricks dashboards and Tableau
Goals and scope
The goal was a less complex data landscape. Fewer tools were meant to make onboarding easier, reduce the dependence on individual experts for individual tools, and allow uniform administration. That was meant to relieve the BI and tech team and free capacity for work with business impact. To get there we replaced BigQuery completely. The cost check on every query went away with it.
The scope covered the historical data in BigQuery, the ongoing data feeds, the transformations behind the published tables, and every report that read those tables. It also covered the automations and admin workflows in Retool and the switch to Snowplow for tracking. The application databases themselves stayed as they were.
A data product counted as migrated when it met three conditions. Its business figures agreed between source and target at the same data state. The tests on keys, required fields and relationships passed. The connected reports showed the same results on the new tables. The project was complete when nothing accessed BigQuery any more.
Implementation in four stages
Move the history and the ongoing feeds
- What I decided
- I had the historical data exported once and the ongoing feeds caught up until the switch. We stored the raw data unchanged in a bronze layer. That let us repeat any later transformation from the same data.
- What the team implemented
- We exported the BigQuery tables as Parquet files, transferred them to S3 and loaded them into Databricks as Delta tables with PySpark. Each load received a batch ID so that a repeated import did not create a second copy.
- How we checked completion
- We compared row counts and business figures per table as of the export date. For the ongoing feeds we also checked that late-arriving records reached the target and that a rerun wrote no duplicates. The example below reconstructs this check.
Check with a late event
Reconstructed example with synthetic data, executed in SQLite. It shows the principle of the check and contains no original project data.
The 10:00 UTC export contained E100 and E101. The test replayed the ongoing deliveries from position 101 through 103. E101 appeared in both inputs. E102 occurred before the export and arrived afterwards.
Events in the historical export Event ID Occurred (UTC) E100 2026-10-05 09:45 E101 2026-10-05 09:55 Ongoing deliveries in UTC Position Event ID Occurred Delivered 101 E101 2026-10-05 09:55 2026-10-05 09:56 102 E102 2026-10-05 09:58 2026-10-05 10:04 103 E103 2026-10-05 10:06 2026-10-05 10:07 104 E104 2026-10-05 10:08 2026-10-05 10:09 Reconciliation through position 103 Step Target rows Rows written Missing Unexpected After export load 2 2 2 0 After catch-up 4 2 0 0 After retry 4 0 0 0 The catch-up added E102 and E103. The target matched all four reference events through position 103. The second replay wrote zero rows.
Show the executed SQL and reproduction command
node scripts/verify-migration-evidence.jsWITH incoming AS ( SELECT event_id, occurred_at FROM legacy_snapshot UNION ALL SELECT event_id, occurred_at FROM live_feed WHERE source_position BETWEEN $replay_start AND $through_position ) INSERT INTO target_events (event_id, occurred_at) SELECT event_id, occurred_at FROM incoming WHERE TRUE ON CONFLICT(event_id) DO NOTHING;WITH missing AS ( SELECT event_id, occurred_at FROM source_at_boundary EXCEPT SELECT event_id, occurred_at FROM target_events ), unexpected AS ( SELECT event_id, occurred_at FROM target_events EXCEPT SELECT event_id, occurred_at FROM source_at_boundary ) SELECT 'missing' AS status, event_id AS eventId, occurred_at AS occurredAt FROM missing UNION ALL SELECT 'unexpected', event_id, occurred_at FROM unexpected ORDER BY status, eventId;Port and simplify the dbt models
- What I decided
- I decided against translating the BigQuery models one to one. Much of what they contained only kept the scanned data volume small and was needlessly complicated on Databricks. We ported the business logic and removed the cost optimization where it no longer served a purpose. In dbt I separated facts and dimensions and defined for each model what a row means and which key makes it unique.
- What the team implemented
- We prepared the raw data with PySpark and rebuilt the business models in dbt. The SQL dialects were not fully compatible. Date and time zone functions, arrays and some data types behaved differently. We adjusted those places model by model.
- How we checked completion
- For models with substantial transformations or aggregations we wrote dbt tests on keys, required fields and relationships. We also compared the business figures with the BigQuery result at the same data state. When a figure differed, we traced it from the total back to the individual records.
Difficulty During the migration dbt introduced Python models and the Semantic Layer. I therefore planned a migration within the migration. We moved a few narrowly defined areas straight to the new features, so we did not port them and then rework them shortly afterwards. We ported all other models without redesign to keep the scope manageable.
An incremental dbt model before and after simplification
Illustrative example. In BigQuery, partitioning, a required filter and clustering limited the data scanned. On Databricks a merge on the key was enough.
dbt on BigQuery
{{ config( materialized='incremental', incremental_strategy='insert_overwrite', partition_by={'field': 'event_day', 'data_type': 'date'}, require_partition_filter=true, cluster_by=['contact_id'] ) }} select event_id, contact_id, event_day, event_type from {{ ref('stg_events') }} {% if is_incremental() %} where event_day >= date_sub(current_date(), interval 3 day) {% endif %}dbt on Databricks
{{ config( materialized='incremental', incremental_strategy='merge', unique_key='event_id' ) }} select event_id, contact_id, event_day, event_type from {{ ref('stg_events') }} {% if is_incremental() %} where loaded_at > (select max(loaded_at) from {{ this }}) {% endif %}The same event day in both SQL dialects
Illustrative example of a place where the dialects differed.
BigQuery GoogleSQL
SELECT DATE(occurred_at, 'Europe/Berlin') AS event_day FROM events;Databricks SQL
SET TIME ZONE 'UTC'; SELECT CAST(from_utc_timestamp(occurred_at, 'Europe/Berlin') AS DATE) AS event_day FROM events;Switch the processing and the tracking
- What I decided
- I moved the processing from ETL to ELT. We loaded first and then transformed on the platform. After a failure the raw data was still there, and we could rerun a corrected model on the same data. I planned the new Snowplow tracking as a separate ingestion path so we could check the arrival of events independently of the models.
- What the team implemented
- Databricks Workflows started loading, preparation, dbt models and tests in a fixed order. If a step failed, the following steps did not start. Snowplow delivered the events into their own tables on the same platform. Invalid events went to an error store and stayed out of the main tables.
- How we checked completion
- I defined minimum levels for the freshness and availability of the data products. The new processing was accepted when the runs met those levels and the tests passed after each run.
Switch the reports and the Retool workflows
- What I decided
- I mapped each data product to the reports that used it and set the order of the switch accordingly. A data product only moved once its consumers had been checked. For Retool I decided to move everything to Databricks that could be built there.
- What the team implemented
- We pointed the read connections of the reports to the new tables. We rebuilt most of the automations and admin workflows from Retool in Databricks. Only top-of-funnel actions that happened before ingestion stayed in Retool. We made their data available as raw tables in Databricks for the ELT. We built new analyses as dashboards in Databricks. They needed no license per user, and reports were easier to share.
- How we checked completion
- We compared the reports before and after the switch using the same figures. When they agreed, we released the data product and removed its access to BigQuery.
Acceptance and handover
We switched each data product over individually. Before each release I brought three checks together: the source-to-target comparison, the dbt tests and the check of the connected reports. Until its release, the consumers of a data product continued to read from BigQuery.
After the last switch we verified that no queries, schedules or service accounts still accessed BigQuery. Then we switched the service off. The team took over operation with defined responsibilities, schedules and a procedure for recovering from the raw data.
Result
BigQuery was switched off. The warehouse, processing, code and reporting then sat on Databricks in our AWS environment. Transformations ran as ELT with dbt, and tracking came through Snowplow.
The team worked with fewer tools. We needed Retool only for actions that happened before ingestion. We developed considerably faster. We no longer had to check each new process for how much data it scanned, because cost no longer depended on the individual query. We managed roles and users in one place instead of in two clouds.
Reporting in Databricks gradually replaced many Tableau dashboards. With no license per user, reports were easier to share, and almost all users moved over. About two years after the migration the company was able to switch Tableau off as well.
I have no measurements of cost or runtime from that period. This section describes what changed in day-to-day work.