-- Frontend/segment events staging table for hook session processing
-- Extracts and processes all frontend events (Android, iOS, Web) before aggregation
-- Uses recommendation_item_id joins for mobile platforms to get hook_session_id

CREATE OR REPLACE TABLE {{ stg_hook_session_segment_events_table_name }} (
    -- Core identifiers
    user_id INTEGER
    , user_uid VARCHAR(255)
    , hook_id VARCHAR(255)
    , hook_session_id VARCHAR(255)
    , recommendation_item_id VARCHAR(255)
    , session_id VARCHAR(255)

    -- Event details
    , event_timestamp TIMESTAMP_NTZ
    , event_type VARCHAR(100)
    , event_count INTEGER
    , platform VARCHAR(20)

    -- Partition fields
    , p_date DATE
    , p_hour INTEGER
)
CLUSTER BY (p_date, p_hour);
