Migrating a dbt Pipeline from PostgreSQL to BigQuery: What Changes and What Doesn’t

· Source: Data Engineering on Medium · Field: Technology & Digital — Data Science & Analytics, Cloud Computing & IT Infrastructure · Depth: Intermediate, short

Summary

A technical account details the migration of a dbt pipeline, originally built on local PostgreSQL for NYC Taxi and Olist datasets, to Google BigQuery. This transition addresses PostgreSQL's limitations in production, such as lack of team accessibility, scalable partitioning, and managed infrastructure. Key changes involved adapting SQL dialect, specifically "CAST" syntax and "EXTRACT(DAYOFWEEK)" functions, and reconfiguring "profiles.yml" for BigQuery's OAuth and service account authentication. New implementations included partitioning by "pickup_datetime" and clustering by "trip_id" for cost optimization, alongside a 3-day lookback window for incremental models. Furthermore, a CI/CD pipeline was established using GitHub Actions, automating 18 dbt tests on every push to the main branch, secured by a dedicated service account with minimal permissions. The core dbt model structure, business logic, and incremental model concepts remained warehouse-agnostic.

Key takeaway

For Data Engineers migrating dbt pipelines to cloud data warehouses like BigQuery, you must account for significant SQL dialect differences and authentication changes beyond just "profiles.yml". Implement BigQuery's native partitioning and clustering on relevant columns, such as "pickup_datetime" and "trip_id", to optimize query costs. Additionally, establish a robust CI/CD pipeline with GitHub Actions and dedicated service accounts to automate data quality checks and ensure production readiness.

Key insights

Migrating dbt pipelines to cloud warehouses requires adapting SQL dialects, authentication, and implementing cloud-native optimizations.

Principles

Method

Migrate dbt by adapting SQL dialect, configuring "profiles.yml" for cloud authentication, implementing partitioning/clustering, and setting up CI/CD with service accounts and GitHub Secrets.

In practice

Topics

Code references

Best for: Data Engineer, MLOps Engineer

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Data Engineering on Medium.