Sitemap
Kumaran C.S

Kumaran C.S

Data Engineer | Snowflake, Python, AWS, dbt & PySpark | Sharing practical data engineering, cloud, AI, and automation learnings.

Member-only story

dbt Models: A Practical Guide

4 min readOct 8, 2026

--

Press enter or click to view image in full size

👉 Not a Medium member? Here’s a link for you!🌟

1. What is a dbt model?

A dbt model is a single .sql file that contains one select statement. dbt turns that query into a table or view in your warehouse. You write the transformation logic, and dbt handles the create table as / create view as boilerplate, dependency ordering, and environment-specific naming.

-- models/staging/stg_orders.sql
select
id as order_id,
user_id as customer_id,
order_date,
status
from {{ source('shop', 'raw_orders') }}

Key rules:

  • One model = one select statement = one file.
  • The file name is the model name (stg_orders.sql creates stg_orders).
  • Models are written in SQL plus Jinja ({{ ... }} and {% ... %}).
  • Models live in the models/ directory (configurable in dbt_project.yml).

2. Building blocks inside a model

  • {{ source('src', 'table') }} Points at a raw table loaded outside dbt.
  • {{ ref('model') }} Points at another dbt model and creates a dependency.
  • {{ config(...) }} Sets options for this model at the top of the file.
  • {{ var('name') }} Reads a project variable.

--

--

Kumaran C.S
Kumaran C.S

Written by Kumaran C.S

Data Engineer | Snowflake, Python, AWS, dbt & PySpark | Sharing practical data engineering, cloud, AI, and automation learnings.