-- 维度扩展
INSERT INTO dim.game_product_relation (relation_id, game_identity, game_platform_id, game_channel_id, product_id, product_name, project_name, studio_id, studio_name, entity_id, entity_name, system_id, system_name, platform_id, platform_name, merchant_id, merchant_name, channel_id, channel_name, divide_type, divide_scale, divide_scale_step)
SELECT
    tt1.relation_id,
    tt1.game_identity,
    tt1.platform_id game_platform_id,
    tt1.channel_id game_channel_id,
    tt2.product_id,
    tt2.product_name,
    tt2.project_id project_name,
    tt2.studio_id,
    tt2.studio_name,
    tt2.entity_id,
    tt2.entity_name,
    tt2.system_id,
    tt2.system_name,
    tt2.platform_id,
    tt2.platform_name,
    tt2.merchant_id,
    tt2.merchant_name,
    tt2.channel_id,
    tt2.channel_name,
    tt2.divide_type,
    tt2.divide_scale,
    tt2.divide_scale_step
FROM
    dws.game_external_relation tt1
    INNER JOIN dws.game_product_relation tt2 ON tt1.relation_id = tt2.relation_id
ON CONFLICT (game_identity,game_platform_id,game_channel_id)
    DO UPDATE SET
        relation_id = EXCLUDED.relation_id,
        product_id = EXCLUDED.product_id,
        product_name = EXCLUDED.product_name,
        project_name = EXCLUDED.project_name,
        studio_id = EXCLUDED.studio_id,
        studio_name = EXCLUDED.studio_name,
        entity_id = EXCLUDED.entity_id,
        entity_name = EXCLUDED.entity_name,
        system_id = EXCLUDED.system_id,
        system_name = EXCLUDED.system_name,
        platform_id = EXCLUDED.platform_id,
        platform_name = EXCLUDED.platform_name,
        merchant_id = EXCLUDED.merchant_id,
        merchant_name = EXCLUDED.merchant_name,
        channel_id = EXCLUDED.channel_id,
        channel_name = EXCLUDED.channel_name,
        divide_type = EXCLUDED.divide_type,
        divide_scale = EXCLUDED.divide_scale,
        divide_scale_step = EXCLUDED.divide_scale_step
;
