-- Create or replace Discord info table with full snapshot from S3
CREATE OR REPLACE TRANSIENT TABLE {discord_info_table_name} AS
SELECT 
    $1:id::NUMBER(38,0) as id,
    $1:user_id::NUMBER(38,0) as user_id,
    $1:uid::VARCHAR(255) as uid,
    $1:clerk_id::VARCHAR(255) as clerk_id,
    $1:has_accepted_tos::BOOLEAN as has_accepted_tos,
    $1:subscription_status::VARCHAR(255) as subscription_status,
    $1:subscription_anchor::VARCHAR(255) as subscription_anchor,
    $1:subscription_cancel_at::VARCHAR(255) as subscription_cancel_at,
    $1:extra_credits_balance::NUMBER(38,0) as extra_credits_balance,
    $1:subscription_period_end::VARCHAR(255) as subscription_period_end,
    $1:subscription_plan_id::VARCHAR(255) as subscription_plan_id,
    $1:extra_credits_used::NUMBER(38,0) as extra_credits_used,
    $1:display_name::VARCHAR(255) as display_name,
    $1:handle::VARCHAR(255) as handle,
    $1:handle_updated_at::VARCHAR(255) as handle_updated_at,
    $1:active_subscription_platform::VARCHAR(255) as active_subscription_platform,
    $1:revcat_subscription_id::VARCHAR(255) as revcat_subscription_id,
    $1:stripe_customer_id::VARCHAR(16777216) as stripe_customer_id,
    $1:stripe_subscription_id::VARCHAR(16777216) as stripe_subscription_id,
    $1:registered_platform::VARCHAR(255) as registered_platform,
    $1:birthday::VARCHAR(255) as birthday,
    $1:phone_number::VARCHAR(255) as phone_number,
    $1:p_date::DATE as p_date,
    $1:p_hour::NUMBER(38,0) as p_hour
FROM {stage_path} (file_format => 'BASIC_PARQUET_LOADER', pattern => ('.*.parquet'));

