{{ 
    config(
    materialized='incremental',
    unique_key=['id', 'type'],
    incremental_strategy='delete+insert',
    on_schema_change='sync_all_columns',
    cluster_by=['p_date', 'p_hour'],
    snowflake_warehouse='DYNAMODB_EVENTS_SMALL'
) }}


SELECT
    id,
    type,
    message_id,
    session_id,
    name,
    content,
    finish_reason,
    sessions,
    tool_call_id,
    tool_calls,
    user_id,
    visibility,
    workspace_id,
    created_at,
    updated_at,
    p_date,
    p_hour
FROM 
    {{ ref('raw_s3_orpheus_ddb') }}
WHERE  
    {{ partition_filter_hourly('p_date', 'p_hour') }} -- Prune to only specific partition
    
