# dbt Core 2026: คู่มือ Analytics Engineering & Data Transformation สำหรับ SME ไทย
ในยุคที่ทุกธุรกิจขับเคลื่อนด้วยข้อมูล แต่ทีม Data ของ SME ไทยมักเจอปัญหาเดิมๆ คือ SQL queries กระจัดกระจายอยู่ในไฟล์ Excel, Google Sheet, BI tools และ Notion — ไม่มี Version Control, ไม่มี Test, ไม่มี Documentation ทำให้ Logic ของ "รายได้รวม" หรือ "Active Customer" แตกต่างกันในแต่ละ Dashboard จนผู้บริหารตัดสินใจผิดพลาด
dbt (Data Build Tool) คือคำตอบของปัญหานี้ ด้วยแนวคิด Analytics Engineering ที่นำ Best Practice ของ Software Engineering อย่าง Git, CI/CD, Testing มาใช้กับ SQL เพื่อให้ทีม Data ทำงานเหมือนทีม Developer และส่งมอบ Data Model ที่เชื่อถือได้ในความเร็วระดับ Production
บทความนี้จะพาคุณรู้จัก dbt Core (Open-Source ใช้ฟรี), เข้าใจ Architecture, ดูขั้นตอนการ Setup จริงสำหรับธุรกิจไทย และเปรียบเทียบกับ dbt Cloud ว่าเหมาะกับใคร
dbt Core คืออะไร? ทำไมถึงเปลี่ยนวงการ Data
dbt Core เป็น Command-Line Tool ที่ทำหน้าที่ "T" (Transform) ในกระบวนการ ELT — คุณ Extract และ Load ข้อมูลดิบเข้า Data Warehouse (BigQuery, Snowflake, Redshift, Postgres) ก่อน แล้วใช้ dbt เปลี่ยนข้อมูลดิบเป็น Data Model พร้อมใช้สำหรับ BI
แทนที่จะเขียน Stored Procedure หรือสคริปต์ Airflow ยาวๆ คุณเขียน SQL ใน `.sql` ไฟล์ + ใส่ `{{ ref('upstream_model') }}` แล้ว dbt จะสร้าง Dependency Graph (DAG) ให้อัตโนมัติ รัน Order ที่ถูกต้อง สร้าง Documentation พร้อม Lineage Diagram ที่ทุกคนเข้าใจได้
| คุณสมบัติ | dbt Core | Stored Procedure แบบเดิม |
|----------|----------|------------------------|
| Version Control | ใช้ Git ได้ทันที | ยากมาก แก้บน DB |
| Testing | Built-in `unique`, `not_null` | ต้องเขียนเอง |
| Documentation | Auto-generated + Lineage | เขียนแยกใน Wiki |
| Reusability | Macro + Jinja | Copy-paste |
| CI/CD | GitHub Actions/GitLab CI | ไม่มี |
Core Concepts: Models, Tests, Sources
dbt มี Building Block หลัก 5 อย่างที่ต้องเข้าใจ:
โครงสร้าง Project มาตรฐานจะแบ่งเป็น 3 Layer ตามแนว Medallion Architecture:
ขั้นตอน Setup dbt Core สำหรับ SME ไทย
ทำตาม 5 Step นี้คุณจะมี Data Pipeline ใช้ได้ภายใน 1 วัน
Step 1: ติดตั้ง dbt Core + Adapter
```bash
# สมมติใช้ BigQuery (เหมาะกับ SME ไทยที่ใช้ Google Workspace อยู่แล้ว)
pip install dbt-bigquery
# หรือถ้าใช้ Postgres ในประเทศ
pip install dbt-postgres
```
Step 2: Init Project
```bash
dbt init my_company_data
cd my_company_data
```
dbt จะสร้างโครงสร้าง Folder + ไฟล์ `dbt_project.yml` + Connection profile ใน `~/.dbt/profiles.yml`
Step 3: ประกาศ Source + เขียน Staging Model
ใน `models/staging/sources.yml`:
```yaml
sources:
tables:
```
ในไฟล์ `models/staging/stg_shopify__orders.sql`:
```sql
select
id as order_id,
customer_id,
cast(total_price as numeric) as gross_amount,
created_at as order_at
from {{ source('shopify', 'orders') }}
where _fivetran_deleted is false
```
Step 4: เขียน Mart Model
ใน `models/marts/fct_orders.sql`:
```sql
select
o.order_id,
o.customer_id,
c.country,
o.gross_amount,
o.order_at
from {{ ref('stg_shopify__orders') }} o
left join {{ ref('stg_shopify__customers') }} c
on o.customer_id = c.customer_id
```
`{{ ref('...') }}` คือหัวใจของ dbt — มันบอกให้ dbt รู้ Dependency และสร้าง DAG ให้
Step 5: รัน + Test
```bash
dbt run # Build models ทั้งหมดตาม DAG
dbt test # รัน Data Tests
dbt docs generate && dbt docs serve # ดู Documentation + Lineage
```
dbt Core vs dbt Cloud: เลือกอะไรดี?
| ปัจจัย | dbt Core (Free) | dbt Cloud (Paid) |
|--------|----------------|------------------|
| ราคา | ฟรี | $100/dev/month ขึ้นไป |
| Scheduler | ใช้ Airflow/Cron/GitHub Actions | Built-in |
| IDE | ใช้ VS Code | Web IDE มี Auto-complete |
| CI/CD | DIY บน GitHub Actions | Built-in Slim CI |
| Hosting | Self-host | Managed |
| เหมาะกับใคร | ทีม Dev > 1 คน, ต้องการคุม Cost | ทีม Analytics ที่ไม่อยาก Setup Infra |
คำแนะนำสำหรับ SME ไทย: เริ่มที่ dbt Core + GitHub Actions ก่อน เพราะฟรีและ Flexible ถ้าทีมโตเป็น 5+ คนค่อยพิจารณา dbt Cloud หรือใช้ Open-Source IDE อย่าง VS Code + dbt Power User Extension ก็ได้
Best Practices ที่ต้องทำตั้งแต่วันแรก
หลังจากเห็นทีม Data หลายแห่งสร้าง Technical Debt จากการละเลยพื้นฐาน เราขอแนะนำ:
Use Case ที่ SME ไทยใช้ได้จริง
dbt ไม่ใช่เครื่องมือสำหรับองค์กรใหญ่อย่างเดียว ต่อไปนี้คือ Use Case ที่เห็นจริงในตลาดไทย:
ปัญหาที่พบบ่อย + วิธีแก้
สรุป + Next Step
dbt Core เป็นเครื่องมือที่ฟรี Mature และมี Community ที่แข็งแรงที่สุดในวงการ Modern Data Stack ปี 2026 ไม่มีเหตุผลที่ SME ไทยจะไม่นำมาใช้ ถ้าคุณยังเขียน SQL กระจัดกระจายในไฟล์ Excel หรือ Stored Procedure การ Migrate มา dbt จะคืนทุนภายใน 3 เดือนแน่นอน — ทั้งจาก Cloud Cost ที่ลดลง, Time-to-Insight ที่เร็วขึ้น และ Data Trust ที่กลับมา
Next Step ของคุณ:
1. ลองทำ Tutorial dbt Jaffle Shop (1 ชั่วโมง)
2. Setup dbt Core + GitHub Actions ใน Project นำร่อง
3. ปรึกษาทีม ADS FIT เพื่อวางสถาปัตยกรรม Data Stack ที่เหมาะกับธุรกิจคุณ
หากต้องการคำแนะนำในการนำ dbt มาใช้กับ Data Warehouse ของบริษัท หรืออ่านบทความ Modern Data Stack อื่นๆ [ติดต่อเรา](/#contact) หรือดูบทความเพิ่มเติมที่ [Blog](/blog) ของ ADS FIT