/

Loading...
Consistent naming makes your dbt project easier to understand and maintain.
| Type | Pattern | Example |
|---|---|---|
| Staging | stg_[source]__[entity] | stg_stripe__customers |
| Intermediate | int_[entity]__[description] | int_orders__pivoted |
| Dimension | dim_[entity] | dim_customers |
| Fact | fct_[event] | fct_orders |
| Metric | mrt_[metric] | mrt_daily_revenue |
[entity]_id (customer_id, order_id)[event]_date (order_date, created_date)[event]_at (created_at, updated_at)is_[state] or has_[thing][description]_amount (order_amount)[thing]_count (order_count)with
source as (
-- Always name the first CTE 'source' when selecting from source/ref
select * from {{ ref('stg_ecommerce__orders') }}
),
renamed as (
-- Use 'renamed' for column renaming operations
select ... from source
),
filtered as (
-- Use 'filtered' when applying WHERE clauses
select ... from renamed where ...
),
aggregated as (
-- Use 'aggregated' for GROUP BY operations
select ... from filtered group by ...
),
final as (
-- Always name the last CTE 'final'
select ... from aggregated
)
select * from final