CREATE TRANSIENT TABLE IF NOT EXISTS {{ dim_user_table_name }} (
    -- Primary Identifiers
    user_id NUMBER PRIMARY KEY COMMENT 'Internal user ID from Discord info table',
    user_uid VARCHAR(255) UNIQUE COMMENT 'Unique user identifier (Discord UID)',
    clerk_id VARCHAR(255) UNIQUE COMMENT 'Clerk authentication service user ID',

    -- Account Information
    email VARCHAR(255) COMMENT 'User email address from auth system',
    phone_number VARCHAR(255) COMMENT 'User phone number if provided',
    handle VARCHAR(255) COMMENT 'User handle/username',
    display_name VARCHAR(255) COMMENT 'User display name or full name',
    
    -- User Metadata
    user_joined_at TIMESTAMP_NTZ(9) COMMENT 'Timestamp when user first joined the platform',
    registered_platform VARCHAR(255) COMMENT 'Platform where user originally registered (web, ios, android)',
    signup_country VARCHAR(255) COMMENT 'Country where user signed up (derived from earliest events)',
    recent_country VARCHAR(255) COMMENT 'Most frequent country from recent session data',
    recent_city VARCHAR(255) COMMENT 'Most frequent city from recent session data',
    birthday VARCHAR(255) COMMENT 'User birthday if provided',
    is_staff BOOLEAN COMMENT 'Whether user is a staff member or has @suno.com/@suno.ai email',
    
    -- Subscription Information
    has_active_subscription BOOLEAN COMMENT 'Whether user has an active paid subscription',
    current_subscription_tier VARCHAR(255) COMMENT 'Current subscription plan name/tier',
    stripe_customer_id VARCHAR(255) COMMENT 'Stripe customer ID for payment processing',
    stripe_subscription_id VARCHAR(255) COMMENT 'Stripe subscription ID for payment processing',
    revcat_customer_id VARCHAR(255) COMMENT 'RevenueCat customer ID (mobile subscriptions)',
    revcat_subscription_id VARCHAR(255) COMMENT 'RevenueCat subscription ID (mobile subscriptions)',
    
    -- Partitioning and Status
    p_date DATE NOT NULL COMMENT 'Partition date for data processing (derived from user_joined_at)',
    p_hour INTEGER NOT NULL COMMENT 'Partition hour 0-23 (derived from user_joined_at)',
    earliest_frontend_event_timestamp TIMESTAMP_TZ(9) DEFAULT NULL COMMENT 'Timestamp of the earliest frontend event for this user',
    is_deleted BOOLEAN COMMENT 'Soft delete flag - true if user no longer exists in source system'
) CLUSTER BY (p_date, p_hour)
COMMENT = 'Dimension table containing comprehensive user information including account details, subscription status, geographic data, and platform metadata';