renyupeng 3 years ago
parent
commit
60ef53288e

+ 3 - 65
Apietl/bytedance_etl/Q4Task/AppBytedanceFileVideoGet.py

@@ -175,74 +175,12 @@ from (
       group by code, tag_category_id, tag_category_name, parent_id, parent_name) m
      on v.signature = m.code
          left join (
-    select stat_datetime, signature, sum
-    from (
-             select stat_datetime, signature, sum, row_number() over (partition by signature order by sum) as rn
-             from (
-                      select stat_datetime,
-                             signature,
-                             sum(cost) over (partition by signature order by stat_datetime) as sum
-                      from (
-                               select stat_datetime, video.signature, cost
-                               from (select material_id, signature, create_time
-                                     from (select material_id, create_time, signature,
-                                                  row_number() over (partition by material_id order by create_time) as rn
-                                           from media_api.bytedance_file_video_get
-                                           where material_id is not null  and date_format(create_time, '%Y-%m-%d') >=
-                                                             date_sub('{date_time}', INTERVAL 6 DAY)
-                                     )s    where rn =1) video
-                                        inner join
-                                    (
-                                        select stat_datetime, material_id, sum(cost) as cost
-                                        from media_api.bytedance_material_report_daily 
-                                        where image_mode in (
-                                                             'CREATIVE_IMAGE_MODE_VIDEO',
-                                                             'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL',
-                                                             'CREATIVE_IMAGE_MODE_UNION_SPLASH_VIDEO'
-                                            )
-                                        group by stat_datetime, material_id
-                                    ) rep
-                                    on video.material_id = rep.material_id
-                               where rep.stat_datetime between date_format(video.create_time, '%Y%m%d') and date_format(date_add(video.create_time, INTERVAL 6 DAY), '%Y%m%d')) t) t
-             where sum >= 5000
-         ) t
-    where rn = 1
+   select signature,effect_date as stat_datetime  from application.effect_material where media_id =1 
 ) effect
                    on v.signature = effect.signature
          left join (
-    select stat_datetime, signature, sum
-    from (
-             select stat_datetime, signature, sum, row_number() over (partition by signature order by sum) as rn
-             from (
-                      select stat_datetime,
-                             signature,
-                             sum(cost) over (partition by signature order by stat_datetime) as sum
-                      from (
-                               select stat_datetime, video.signature, cost
-                               from (select material_id, signature, create_time
-                                     from (select material_id, signature, create_time
-                                     from (select material_id, create_time, signature,
-                                                  row_number() over (partition by material_id order by create_time) as rn
-                                           from media_api.bytedance_file_video_get
-                                           where material_id is not null and date_format(create_time, '%Y-%m-%d') >=
-                                                             date_sub('{date_time}', INTERVAL 6 DAY)
-                                     )s    where rn =1) video
-                                        inner join
-                                    (
-                                        select stat_datetime, material_id, sum(cost) as cost
-                                        from media_api.bytedance_material_report_daily
-                                        where image_mode in (
-                                                             'CREATIVE_IMAGE_MODE_VIDEO',
-                                                             'CREATIVE_IMAGE_MODE_VIDEO_VERTICAL',
-                                                             'CREATIVE_IMAGE_MODE_UNION_SPLASH_VIDEO'
-                                            ) 
-                                        group by stat_datetime, material_id
-                                    ) rep
-                                    on video.material_id = rep.material_id
-                               where rep.stat_datetime between date_format(video.create_time, '%Y%m%d') and date_format(date_add(video.create_time, INTERVAL 13 DAY), '%Y%m%d')) t) t
-             where sum >= 50000
-         ) t
-    where rn = 1
+  select signature,hot_date as stat_datetime from application.hot_material where media_id =1 
+
 ) hot
                    on v.signature = hot.signature
 group by advertiser_id, id, v.signature, material_id, tag_category_id, parent_id, tag_code  

+ 3 - 68
Apietl/kwai_etl/Q4Task/AppKuaishouVideoList.py

@@ -160,77 +160,12 @@ class AppKuaishouVideoList:
                   group by code, tag_category_id, tag_category_name, parent_id, parent_name) m
                  on v.signature = m.code
                      left join (
-                select stat_date, signature, sum
-                from (
-                         select stat_date, signature, sum, row_number() over (partition by signature order by sum) as rn
-                         from (
-                                  select stat_date,
-                                         signature,
-                                         sum(cost) over (partition by signature order by stat_date) as sum
-                                  from (
-                                           select rep.stat_date, video.signature, cost
-                                           from (select photo_id, signature, stat_date
-                                                 from (select photo_id,
-                                                              stat_date,
-                                                              signature,
-                                                              row_number() over (partition by photo_id order by stat_date) rn
-                                                       from media_api.kuaishou_video_list
-                                                       where photo_id is not null
-                                                         and photo_id != 0 and account_id ={account_id}
-                                                         and date_format(stat_date, '%Y-%m-%d') >=
-                                                             date_sub('{date_time}', INTERVAL 6 DAY)
-                                                       group by photo_id, signature) s
-                                                 where rn = 1) video
-                                                    left join
-                                                (
-                                                    select stat_date, photo_id, sum(charge) as cost
-                                                    from media_api.kuaishou_material_video_report_daily
-                                                    where photo_id is not null
-                                                      and photo_id != 0 and advertiser_id ={account_id}
-                                                    group by stat_date, photo_id
-                                                ) rep
-                                                on video.photo_id = rep.photo_id
-                                           where rep.stat_date between date_format(video.stat_date, '%Y%m%d') and date_format(date_add(video.stat_date, INTERVAL 6 DAY), '%Y%m%d')) t) t
-                         where sum >= 5000
-                     ) t
-                where rn = 1
+                                select signature,effect_date as stat_date from application.effect_material where media_id =2
+
             ) effect
                                on effect.signature = v.signature
                      left join (
-                select stat_date, signature, sum
-                from (
-                         select stat_date, signature, sum, row_number() over (partition by signature order by sum) as rn
-                         from (
-                                  select stat_date,
-                                         signature,
-                                         sum(cost) over (partition by signature order by stat_date) as sum
-                                  from (
-                                           select rep.stat_date, video.signature, cost
-                                           from (select photo_id, signature, stat_date
-                                                 from (select photo_id,
-                                                              stat_date,
-                                                              signature,
-                                                              row_number() over (partition by photo_id order by stat_date) rn
-                                                       from media_api.kuaishou_video_list
-                                                       where photo_id is not null 
-                                                         and photo_id != 0 and account_id ={account_id}
-                                                         and date_format(stat_date, '%Y-%m-%d') >=
-                                                             date_sub('{date_time}', INTERVAL 13 DAY)
-                                                       group by photo_id, signature) s
-                                                 where rn = 1) video
-                                                    left join
-                                                (
-                                                    select stat_date, photo_id, sum(charge) as cost
-                                                    from media_api.kuaishou_material_video_report_daily
-                                                    where photo_id is not null and advertiser_id ={account_id}
-                                                      and photo_id != 0
-                                                    group by stat_date, photo_id
-                                                ) rep
-                                                on video.photo_id = rep.photo_id
-                                           where rep.stat_date between date_format(video.stat_date, '%Y%m%d') and date_format(date_add(video.stat_date, INTERVAL 13 DAY), '%Y%m%d')) t) t
-                         where sum >= 50000
-                     ) t
-                where rn = 1
+           select signature,hot_date as stat_date from application.hot_material where media_id =2
             ) hot
                                on hot.signature = v.signature
             group by account_id, photo_id, v.stat_date, v.signature, tag_category_id, parent_id, tag_code