INSERT INTO FACT_MEDAL_AWARD (
    game_key, medal_key, country_key, org_key, date_key,
    player_name, medal_count, medal_points
)
SELECT
    (SELECT game_key    FROM DIM_GAME         WHERE game_id    = ${game_id}),
    (SELECT medal_key   FROM DIM_MEDAL        WHERE medal_type = '${medal_type}'),
    ${country_id:isEmpty():ifElse('NULL',
        concat('(SELECT country_key FROM DIM_COUNTRY WHERE country_id = ', ${country_id}, ')'))},
    ${organization_id:isEmpty():ifElse('NULL',
        concat('(SELECT org_key FROM DIM_ORGANIZATION WHERE org_id = ', ${organization_id}, ')'))},
    ${date_key},
    '${player_name}',
    ${medal_count},
    ${medal_points}
FROM DUAL
