Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --===========================================================
- -- Добавляем данные в линки
- --===========================================================
- INSERT INTO GASANTHONY_GAS_YANDEX_RU__DWH.l_admins(hk_l_admin_id,hk_group_id,hk_user_id,load_dt,load_src)
- select
- hash(hg.hk_group_id,hu.hk_user_id),
- hg.hk_group_id,
- hu.hk_user_id,
- now() as load_dt,
- 's3' as load_src
- from GASANTHONY_GAS_YANDEX_RU__STAGING.groups as g
- left join GASANTHONY_GAS_YANDEX_RU__DWH.h_users as hu on g.admin_id = hu.user_id
- left join GASANTHONY_GAS_YANDEX_RU__DWH.h_groups as hg on g.id = hg.group_id
- where hash(hg.hk_group_id,hu.hk_user_id) not in (select hk_l_admin_id from GASANTHONY_GAS_YANDEX_RU__DWH.l_admins);
- INSERT INTO GASANTHONY_GAS_YANDEX_RU__DWH.l_groups_dialogs(hk_l_groups_dialogs,hk_message_id,hk_group_id,load_dt,load_src)
- select
- hash(hd.hk_message_id,hg.hk_group_id),
- hd.hk_message_id,
- hg.hk_group_id,
- now() as load_dt,
- 's3' as load_src
- from GASANTHONY_GAS_YANDEX_RU__STAGING.groups as g
- left join GASANTHONY_GAS_YANDEX_RU__DWH.h_groups as hg on g.id = hg.group_id
- left join GASANTHONY_GAS_YANDEX_RU__STAGING.dialogs as d on g.id = d.message_group
- left join GASANTHONY_GAS_YANDEX_RU__DWH.h_dialogs as hd on d.message_id = hd.message_id
- where hash(hd.hk_message_id,hg.hk_group_id) not in (select hk_l_groups_dialogs from GASANTHONY_GAS_YANDEX_RU__DWH.l_groups_dialogs);
- INSERT INTO GASANTHONY_GAS_YANDEX_RU__DWH.l_user_message(hk_l_user_message,hk_user_id,hk_message_id,load_dt,load_src)
- select
- hash(hu.hk_user_id, hd.hk_message_id),
- hu.hk_user_id,
- hd.hk_message_id,
- now() as load_dt,
- 's3' as load_src
- from GASANTHONY_GAS_YANDEX_RU__STAGING.dialogs as d
- left join GASANTHONY_GAS_YANDEX_RU__DWH.h_dialogs as hd on d.message_id = hd.message_id
- left join GASANTHONY_GAS_YANDEX_RU__STAGING.users u on u.id = d.message_from
- left join GASANTHONY_GAS_YANDEX_RU__DWH.h_users as hu on u.id = hu.user_id
- where hash(hu.hk_user_id, hd.hk_message_id) not in (select hk_l_user_message from GASANTHONY_GAS_YANDEX_RU__DWH.l_user_message);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement