Advertisement
YuvalGai

Untitled

Mar 5th, 2024
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1.  
  2. t_videos_dashboard = {
  3. 'create_or_replace': '''
  4. CREATE OR REPLACE TABLE CANDIVORE.SEMANTIC_LAYER.T_VIDEOS_DASHBOARD AS
  5. select
  6. a.interval_date,
  7. b.league ARENA_GROUP,
  8. b.trophy_group,
  9. b.country,
  10. b.LANGUAGE,
  11. b.platform,
  12. a.current_arena_index,
  13. b.app_version,
  14. b.app_minor_version,
  15. b.payers_segment,
  16. b.ltv_group,
  17. ACTION,
  18. video_type,
  19. REWARD_TYPE,
  20. sum(ad_value) total_ad_value,
  21. count(a.*) total_ads_watched,
  22. count(distinct a.user_id) users
  23. from
  24. (select *,date(derived_tstamp) interval_date from CANDIVORE.PROD.F_VIDEO_WATCHED where date(derived_tstamp) > '2022-10-01') a
  25. LEFT JOIN
  26. (SELECT
  27. user_id
  28. , interval_date
  29. , country
  30. , LANGUAGE
  31. , platform
  32. , app_version
  33. , app_minor_version
  34. , ltv_group
  35. , DATE(first_install_dt) AS install_date
  36. , payers_segment
  37. , CASE
  38. WHEN trophies_cnt < 1500 THEN '0-1500'
  39. WHEN trophies_cnt < 3800 THEN '1500-3800'
  40. WHEN trophies_cnt < 8000 THEN '3800-8000'
  41. WHEN trophies_cnt < 17000 THEN '8000-17000'
  42. WHEN trophies_cnt < 30000 THEN '17000-30000'
  43. ELSE '30000+'
  44. END AS trophy_group
  45. ,CASE
  46. WHEN trophies_cnt < 800 THEN '800'
  47. WHEN finish_arena<=13 THEN 'Studios'
  48. WHEN finish_arena<=22 THEN 'Master_League'
  49. WHEN finish_arena>=23 THEN 'Legends_League'
  50. END league
  51.  
  52. FROM candivore.prod.daily_users_from_params WHERE interval_date >= '2022-10-01') B
  53.  
  54. ON a.user_id = B.user_id AND a.interval_date = B.interval_date
  55.  
  56. GROUP BY
  57. 1,
  58. 2,
  59. 3,
  60. 4,
  61. 5,
  62. 6,
  63. 7,
  64. 8,
  65. 9,
  66. 10,
  67. 11,
  68. 12,
  69. 13,
  70. 14
  71. '''
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement