-- Create a scheduled task to update the agg_play_info_hourly table
CREATE OR REPLACE TASK SUNO_PROD.PROD.USER_AGENT_METADATA_DAILY_INSERT
    WAREHOUSE = SUNO_PROD_OTHER_DAILY_X_SMALL
    schedule='USING CRON 0 6 * * * UTC'
AS
    declare
        start_time TIMESTAMP;
        p_date date;
        p_hour string;
        stage_path string;
        row_count number;
        sql string;
    begin
        start_time := CURRENT_TIMESTAMP();
        p_date := DATE(SYSDATE() - INTERVAL '1 DAY');
        CALL user_agent_metadata_proc(DATE(SYSDATE() - INTERVAL '1 DAY')) into :row_count;
        call TASK_MONITOR_INSERT_PROC('USER_AGENT_METADATA_DAILY_INSERT', :start_time, :row_count, 'SUCCESS', 'DAILY');
    end;
