Write a dbt Python model that runs on Snowpark, Databricks, or BigQuery for logic that's awkward in SQL

domain: docs.getdbt.com · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Create a .py file in the models directory defining a function named model(dbt, session) that returns a DataFrame.
  2. Reference upstream models/sources inside the function via dbt.ref() and dbt.source(), which dbt resolves into DataFrame reads for the target platform.
  3. Understand the execution path per platform: on Snowflake dbt compiles the code into a Snowpark stored procedure; on BigQuery it runs via a managed Spark/Dataproc session; on Databricks it runs via a Spark job cluster.
  4. Return the DataFrame type expected by the platform (Snowpark or pandas on Snowflake; BigFrames, pandas, or Spark on BigQuery; Spark, pandas, or pandas-on-Spark on Databricks).
  5. Run dbt run -s <python_model> and check the platform's own job/cluster logs, since Python models execute as remote jobs outside dbt's normal SQL execution path.

Known gotchas

Related routes

Write dbt unit tests to validate SQL transformation logic without hitting the warehouse for real data
data-engineering · 5 steps · unrated
implement business logic scripting (bls) in a triton python backend model to call other models
docs.nvidia.com/deeplearning/triton-inference-server · 5 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans