-- Usage Plan Discount Offer table for storing mapping between usage plans and discount offers from RDS
-- This table is populated by the Glue job rds_to_s3_billing_usageplandiscountoffer_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 {usage_plan_discount_offer_table_name} CLUSTER BY (p_date, p_hour) (
    -- Primary identifier
    ID VARCHAR(255),                                    -- Unique mapping identifier
    
    -- Timestamps
    CREATED_AT TIMESTAMP_TZ(9),                         -- When the mapping was created
    UPDATED_AT TIMESTAMP_TZ(9),                         -- Last update timestamp
    
    -- References
    DISCOUNT_OFFER_ID VARCHAR(255),                     -- Associated discount offer identifier
    USAGE_PLAN_ID VARCHAR(255),                         -- Associated usage plan identifier
    
    -- Partitioning columns for optimization
    P_DATE DATE,                                        -- Partition date based on created_at
    P_HOUR NUMBER(38,0)                                 -- Partition hour (0-23) based on created_at
);

