惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

NISL@THU
NISL@THU
Latest news
Latest news
Scott Helme
Scott Helme
T
Tenable Blog
Simon Willison's Weblog
Simon Willison's Weblog
T
The Exploit Database - CXSecurity.com
C
CERT Recently Published Vulnerability Notes
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
K
Kaspersky official blog
The Hacker News
The Hacker News
Jina AI
Jina AI
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cisco Blogs
S
Secure Thoughts
雷峰网
雷峰网
Project Zero
Project Zero
T
Troy Hunt's Blog
IT之家
IT之家
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - Franky
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Know Your Adversary
Know Your Adversary
爱范儿
爱范儿
博客园 - 聂微东
N
News and Events Feed by Topic
The Cloudflare Blog
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Schneier on Security
Schneier on Security
Recent Announcements
Recent Announcements
博客园 - 三生石上(FineUI控件)
大猫的无限游戏
大猫的无限游戏
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Vercel News
Vercel News
C
Check Point Blog
Cisco Talos Blog
Cisco Talos Blog
Apple Machine Learning Research
Apple Machine Learning Research
量子位
C
Cyber Attacks, Cyber Crime and Cyber Security
TaoSecurity Blog
TaoSecurity Blog
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
P
Palo Alto Networks Blog
云风的 BLOG
云风的 BLOG

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
SQLMesh for dbt users: the migration path
Borys Genera · 2026-05-15 · via DEV Community

How to move from dbt to SQLMesh, understand the plan/apply cycle, leverage native column-level lineage, and run dev environments without schema suffixing.

What you get: an introduction to SQLMesh's core differences, the exact commands to run, how tests became audits, how dev environments work, and screenshots from a running demo.

What is dbt

Data Build Tool (dbt) is an open-source framework that allows analysts and engineers to transform data in their warehouses by writing SQL SELECT statements enriched with Jinja templating. This special syntax adds dynamic logic—like loops, variables, and dependency referencing—directly into your SQL. Instead of manually writing CREATE TABLE statements, dbt takes your templated queries and automatically materializes them in the database for you. When a data platform scales, nested Jinja templates become impossible to debug, and copying production data to build staging environments gets expensive fast.

Standard dbt documentation and data catalog interface

What is SQLMesh

This is where SQLMesh comes in. As a modern framework challenging the status quo for the transformation (the 'T') phase of ETL/ELT pipelines, SQLMesh is designed specifically to address these growing pains. It provides a more robust, scalable way to manage data transformations by bringing strict software engineering practices—like stateful dry runs and zero-copy environments—directly into the data warehouse. Because it solves the exact operational bottlenecks that slow down mature data teams, it has rapidly grown in popularity, ultimately leading to its contribution to the Linux Foundation in March 2026.


Under the Hood: Text Templating vs. AST Parsing

The fundamental difference between dbt and SQLMesh comes down to how they read your code.

dbt is a text templater. It uses Jinja to stitch strings of SQL together and sends the final block to the data warehouse to execute. It doesn't semantically understand the SQL it generates.

SQLMesh is a semantic parser. It reads your code and builds an Abstract Syntax Tree (AST) using its underlying engine, SQLGlot. Because SQLMesh understands your SQL before it hits the warehouse, it knows exactly which columns are being selected, aliased, or joined at compile time.

Because SQLMesh actually reads your code, it does three things that dbt cannot do natively:

  1. A Terraform-like plan/apply cycle that guarantees you know the exact impact before spending warehouse compute.
  2. Column-level lineage natively, without requiring expensive third-party data catalogs.
  3. Virtual Data Environments that allow developers to test changes in isolation without physically copying production data.

The plan/apply cycle: seeing the impact

In dbt, you run dbt run and wait to see what breaks. In SQLMesh, you use a stateful workflow inspired by Terraform: plan and apply.

sqlmesh plan

Enter fullscreen mode Exit fullscreen mode

This command evaluates your local SQL files against the current state of the database and generates an execution plan. It outputs exactly what will be built, whether it's a full refresh or incremental, and asks for confirmation:

======================================================================
Plan: prod
======================================================================
New environment `prod` will be created from `empty`

Added Models:
├── jaffle_shop.customers    (Full Refresh)
└── jaffle_shop.orders (Full Refresh)

Apply - Create prod environment and backfill models [y/n]:

Enter fullscreen mode Exit fullscreen mode

When you add a column to customers.sql, the next sqlmesh plan highlights the exact impact before any warehouse compute is consumed. It knows that downstream models must be rebuilt because the upstream schema changed:

Directly Modified:
└── jaffle_shop.customers (Full Refresh)
      + phone_number TEXT

Indirectly Modified:
└── jaffle_shop.orders — upstream schema changed, will be rebuilt

Apply - Update prod environment and backfill models [y/n]:

Enter fullscreen mode Exit fullscreen mode

You review the impact, then type y to apply. You stop paying for blind warehouse queries just to see if your code works.

The plan and apply execution from the running demo looks like this:
SQLMesh showing the plan evaluation

SQLMesh showing the plan application


Column-level lineage out of the box

Because SQLMesh uses SQLGlot to parse your SQL, it natively understands how data flows from source to destination at the column level. It traces dependencies through complex aliases, window functions, and joins without you ever writing a YAML definition.

SQLMesh does have a dbt-docs-style DAG view, but it is exposed through the data catalog and lineage graph instead of a separate static docs site. The useful difference is that the graph is tied to the selected SQLMesh environment and can show model fields, not only model boxes.

SQLMesh data catalog listing the migrated models

The lineage view for the demo model looks like this. The point is not that SQLMesh has a DAG. dbt already has that. The useful part is column visibility: you can inspect which upstream columns feed a downstream model, which is what makes impact analysis and PII tracing practical.

In this small demo, the graph shows seed_model feeding incremental_model, then full_model, with the columns visible on each node.

SQLMesh UI lineage graph

Use Case 1: Safe Deprecation of Columns

Say you need to drop a deprecated user_phone column from the production database.

In a dbt setup, understanding the full impact is problematic. You would have to do a global text search for user_phone across hundreds of SQL files. Even then, if the column was aliased (SELECT user_phone AS phone_number), a simple text search might miss downstream models that rely on phone_number.

SQLMesh solves this instantly. By parsing the AST, it tracks the column through every alias and CTE. You simply open the built-in UI editor and click the column name.

It visually traces and highlights exactly which downstream reporting tables or BI dashboards will break if you drop the source column. You can confidently deprecate columns without causing massive data outages.

Use Case 2: Tracing PII Data for Compliance

Data privacy regulations (like GDPR or CCPA) require strict tracking of Personally Identifiable Information (PII). If you mistakenly join a table containing an email_address into a public-facing metrics aggregate, it could result in a massive compliance violation.

With SQLMesh, you can visually trace the flow of sensitive data using the built-in UI:

sqlmesh ui

Enter fullscreen mode Exit fullscreen mode

This spins up a local web server displaying an interactive lineage graph. Visually, the lineage mapping ensures you can audit exactly where email or ssn flows:

graph LR
    A[jaffle_shop.raw_customers<br><i>email</i> (PII)] --> C(jaffle_shop.stg_customers<br><i>email</i>)
    C --> D(jaffle_shop.customers<br><i>email</i>)

    style A fill:#bf616a,stroke:#d08770,color:#eceff4
    style C fill:#3b4252,stroke:#a3be8c,color:#eceff4
    style D fill:#3b4252,stroke:#a3be8c,color:#eceff4

Enter fullscreen mode Exit fullscreen mode

Because the lineage is native, data governance teams can instantly verify that PII is masked or excluded before it reaches downstream aggregates.


Dev environments without schema suffixing (Virtual Environments)

This is how SQLMesh directly cuts warehouse compute costs.

In dbt, a development environment is physical. It's a target schema (e.g., analytics_dev_yourname). When you build your models to test a change, you physically copy or rebuild the data into your dev schema.

In SQLMesh, a dev environment is a Virtual Data Environment.

When you run sqlmesh plan dev, SQLMesh doesn't copy data. Instead, it creates lightweight, virtualized database views that simply point to the existing physical tables from prod.

The SQLMesh UI keeps those environments visible in the same toolbar used by the editor, plan view, and data catalog. In this demo, prod and dev both exist, and prod is marked as the production environment.

SQLMesh UI environment

flowchart TD
    subgraph Physical Storage
        P1[(jaffle_shop.customers_v1 <br> 100M rows)]
        P2[(jaffle_shop.customers_v2 <br> 100M rows)]
        P3[(jaffle_shop.orders_v1 <br> 500M rows)]
    end

    subgraph PROD Environment Views
        V_PROD_C(jaffle_shop.customers) -. points to .-> P1
        V_PROD_O(jaffle_shop.orders) -. points to .-> P3
    end

    subgraph DEV Environment Views
        V_DEV_C(jaffle_shop__dev.customers) -. points to .-> P2
        V_DEV_O(jaffle_shop__dev.orders) -. points to .-> P3
    end

Enter fullscreen mode Exit fullscreen mode

Use Case 1: Multi-Developer Collaboration (Dev)

In a fast-moving data team, multiple developers are working on different features simultaneously. Alice is updating the customers model, and Bob is updating the orders model.

In traditional setups, Alice and Bob either step on each other's toes in a shared staging schema, or they both have to spend 20 minutes copying gigabytes of data into alice_dev and bob_dev schemas before they can start working.

With SQLMesh, Alice simply creates her own virtual environment (sqlmesh plan alice_feature). SQLMesh builds only her modified customers table physically, while her orders view points to the production physical table. Bob does the same for his feature. They get perfect isolation instantly, with zero duplicated data and zero wasted compute cost.

Use Case 2: Instant Rollbacks and Blue/Green Deployments (Prod)

Deploying pipeline changes to production is risky. A flawed query can corrupt downstream tables and break executive BI dashboards.

SQLMesh handles production deployments using Blue/Green deployments natively via virtual environments.

When you merge your code to main and deploy, SQLMesh builds the new physical tables in the background (the "Green" state). Your prod environment views still point to the old tables (the "Blue" state).

Once the new tables are fully built, populated, and automatically audited for quality, SQLMesh simply updates the prod views to point to the new physical tables. This pointer swap takes milliseconds. If a bug is discovered after deployment, you can instantly rollback by swapping the view pointers back to the previous physical tables. No data needs to be rebuilt, providing a massive safety net for data teams.


Upgrading a Model: dbt vs SQLMesh

Here is what this looks like in practice. We need to build a customers model that cleans up user data from jaffle_shop.stg_customers and joins it with jaffle_shop.orders to calculate lifetime value.

In dbt, you first write the SQL template (models/customers.sql):

{{ config(
    materialized='table'
) }}

WITH customer_orders AS (
  SELECT
    customer_id,
    MIN(order_date) AS first_order_date,
    MAX(order_date) AS most_recent_order_date,
    COUNT(*) AS number_of_orders,
    SUM(amount) AS customer_lifetime_value
  FROM {{ ref('orders') }}
  WHERE status <> 'returned'
  GROUP BY customer_id
)

SELECT
  c.customer_id,
  c.customer_name,
  c.email,
  c.signup_date,
  o.first_order_date,
  o.most_recent_order_date,
  COALESCE(o.number_of_orders, 0) AS number_of_orders,
  COALESCE(o.customer_lifetime_value, 0) AS customer_lifetime_value
FROM {{ ref('stg_customers') }} AS c
LEFT JOIN customer_orders AS o
  ON c.customer_id = o.customer_id

Enter fullscreen mode Exit fullscreen mode

But you're not done. In dbt, your SQL file only contains the logic. To validate that the output data is actually correct—for example, to test that your customer_id is unique and never null—you have to leave your SQL file, open a completely separate YAML configuration file (models/schema.yml), and write your validation tests there:

version: 2
models:
  - name: customers
    columns:
      - name: customer_id
        tests:
          - unique
          - not_null

Enter fullscreen mode Exit fullscreen mode

The dbt docs graph for this looks like this:

dbt docs lineage graph

When you migrate this same model to SQLMesh, the scattered configuration disappears. Everything—metadata, dependencies, materialization logic, and testing—consolidates into the SQL file itself via the MODEL block.

SQLMesh UI Editor

MODEL (
  name jaffle_shop.customers,
  kind FULL,
  grain customer_id
);

WITH customer_orders AS (
  SELECT
    customer_id,
    MIN(order_date) AS first_order_date,
    MAX(order_date) AS most_recent_order_date,
    COUNT(*) AS number_of_orders,
    SUM(amount) AS customer_lifetime_value
  FROM jaffle_shop.orders
  WHERE status <> 'returned'
  GROUP BY customer_id
)

SELECT
  c.customer_id::INT AS customer_id,
  c.customer_name::TEXT AS customer_name,
  c.email::TEXT AS email,
  c.signup_date::DATE AS signup_date,
  o.first_order_date::DATE AS first_order_date,
  o.most_recent_order_date::DATE AS most_recent_order_date,
  COALESCE(o.number_of_orders, 0)::INT AS number_of_orders,
  COALESCE(o.customer_lifetime_value, 0)::DOUBLE AS customer_lifetime_value
FROM jaffle_shop.stg_customers AS c
LEFT JOIN customer_orders AS o
  ON c.customer_id = o.customer_id

Enter fullscreen mode Exit fullscreen mode

Notice what happened here:

  1. No Jinja Refs: You simply query jaffle_shop.stg_customers and jaffle_shop.orders using standard SQL. Because SQLMesh parses the AST, it automatically detects the dependencies for both tables.
  2. No YAML Tests: The grain customer_id property inside the MODEL block automatically declares the natural key. You do not need to write explicit tests. When you want to validate the data, you simply run sqlmesh audit in the terminal, and SQLMesh will automatically generate and execute the uniqueness and not-null validation checks for you based on that grain.

The generated DAG for this model in SQLMesh looks like this:

SQLMesh static DAG generated from the migrated project

This is the closest match to the familiar dbt docs graph: a model dependency DAG generated from parsed SQL. The browser UI goes one step further by letting you inspect the same dependency chain with environment context and column metadata.

If you want to try this yourself locally (using DuckDB, so no warehouse account needed), installation is simple:

pip install "sqlmesh[duckdb]"
mkdir sqlmesh-demo && cd sqlmesh-demo
sqlmesh init -t empty

Enter fullscreen mode Exit fullscreen mode


Automating this with CI/CD (GitHub Actions)

The plan/apply cycle and virtual environments are impressive locally, but they become a superpower when integrated into your CI/CD pipeline.

SQLMesh provides a native GitHub Action (TobikoData/sqlmesh-action) that automates this entire workflow:

  1. The PR Plan: When a developer opens a Pull Request, the GitHub Action automatically creates a temporary Virtual Environment (e.g., pr_123) and runs a plan.
  2. Automated Review: The bot posts the exact execution plan as a comment directly on the PR. The reviewer instantly sees which models are modified and which downstream models will be impacted, without having to run anything locally.
  3. Zero-Copy Deployment: Upon merging to main, the deployment job doesn't need to rebuild the data. It simply swaps the pointers in the prod environment to reference the physical tables that were already built and tested during the PR.

This guarantees that main is always in a deployable state and developers never accidentally merge breaking schema changes into production.


Final thoughts

Moving from text-based templating to semantic AST parsing is the structural shift required to solve data environment bloat and lineage blindness.

To evaluate this transition yourself:

  • Audit your current warehouse spend strictly related to developer sandbox schemas.
  • Run sqlmesh init --template dbt on a local branch of your existing dbt project.
  • Migrate 5 connected models to the MODEL block syntax.
  • Execute sqlmesh plan dev to observe the virtual pointer creation in your warehouse.

When the tool understands the code, the infrastructure manages itself.

Q: Do I need to rewrite all my dbt SQL immediately?
No, SQLMesh can parse and run your existing Jinja-based dbt models directly using its dbt adapter.

Q: Does SQLMesh require DuckDB?
No, DuckDB is just used here for a fast local demo; SQLMesh natively supports Snowflake, BigQuery, Databricks, and Redshift.

Q: How does SQLMesh handle dbt macros?
It executes existing dbt macros perfectly during the transition, though rewriting them as native Python macros eventually unlocks deeper AST-level validation.

Q: Is this relevant if my team only has three data models?
The immediate value for small teams is the automated testing and plan visibility, but the cost savings of virtual environments truly compound at scale.