-- Playlist Clip table for storing playlist-clip associations
-- This table is populated by the Glue job rds_to_s3_bots_playlist_clip_hourly_upsert
-- which dumps data from RDS to S3 and then loads it into Snowflake
-- Clustered by partition date and hour for optimal query performance
CREATE TRANSIENT TABLE IF NOT EXISTS {playlist_clip_table_name} CLUSTER BY (p_date, p_hour) (
    -- Primary identifier
    ID NUMBER(38,0),                                    -- Unique identifier
    
    -- Playlist details
    RELATIVE_INDEX NUMBER(38,0),                        -- Position in playlist (ordering)
    CLIP_ID VARCHAR(255),                               -- Clip identifier
    PLAYLIST_ID VARCHAR(255),                           -- Playlist identifier
    
    -- Session information
    CREATED_SESSION_ID VARCHAR(255),                    -- Session that created this entry
    
    -- User tracking
    UPDATED_BY_ID NUMBER(38,0),                         -- User who updated the playlist
    
    -- Timestamps
    UPDATED_AT TIMESTAMP_TZ(9),                         -- Last update timestamp
    
    -- Partitioning columns for optimization
    P_DATE DATE,                                        -- Partition date based on updated_at
    P_HOUR NUMBER(38,0)                                 -- Partition hour (0-23) based on updated_at
);
