dbt Model Generation
Overview
Generated Artifacts
1. dbt Model SQL
{{
config(
materialized='table',
tags=['auto-generated', 'dimension', 'customer'],
description='Customer dimension table with standardized attributes'
)
}}
with source_data as (
select
customer_id,
first_name,
last_name,
email,
phone,
created_date,
updated_date
from {{ source('raw_crm', 'customers') }}
),
transformed as (
select
-- Surrogate key
{{ dbt_utils.surrogate_key(['customer_id']) }} as customer_sk,
-- Business key
cast(customer_id as string) as customer_bk,
-- Standardized names
initcap(trim(first_name)) as first_name,
initcap(trim(last_name)) as last_name,
trim(concat(
initcap(trim(first_name)),
' ',
initcap(trim(last_name))
)) as full_name,
-- Contact information
lower(trim(email)) as email_address,
regexp_replace(phone, r'[^\d]', '') as phone_number,
-- Temporal attributes
cast(created_date as date) as customer_created_date,
cast(updated_date as timestamp) as last_updated_ts,
-- Audit columns
current_timestamp() as created_at,
current_timestamp() as updated_at,
true as is_active
from source_data
)
select * from transformed2. YAML Documentation
Generated Model Types
1. Dimension Tables
2. Fact Tables
3. Staging Tables
Customization Options
1. Model Configuration
2. Transformation Templates
3. Testing Standards
Advanced Features
1. Incremental Models
2. Slowly Changing Dimensions
3. Data Quality Monitoring
Integration with dbt Packages
1. dbt-utils Integration
2. dbt-expectations Integration
Performance Optimization
1. Partitioning and Clustering
2. Query Optimization
Validation and Testing
1. Model Compilation
2. Data Quality Testing
3. Documentation Generation
Monitoring and Maintenance
1. Model Performance Monitoring
2. Automated Alerts
3. Model Evolution
Last updated