-- Survey Responses table for storing survey response data from RDS
-- This table is populated by the Glue job rds_to_s3_bots_surveyresponses_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 {survey_responses_table_name} CLUSTER BY (p_date, p_hour) (
    -- Primary identifier
    ID VARCHAR(255),                                    -- Unique response identifier
    
    -- Response content
    RESPONSE STRING,                                    -- User's response text/data
    
    -- References
    QUESTION_ID VARCHAR(255),                           -- ID of the question being answered
    USER_ID NUMBER(38,0),                               -- ID of the user who responded
    
    -- Timestamps
    CREATED_AT TIMESTAMP_TZ(9),                         -- When the response was created
    UPDATED_AT TIMESTAMP_TZ(9),                         -- Last update timestamp
    
    -- Partitioning columns for optimization
    P_DATE DATE,                                        -- Partition date based on created_at
    P_HOUR INT                                          -- Partition hour (0-23) based on created_at
);

