dicemy's picture
Upload 655 files
e8c001c verified
Raw
History Blame Contribute Delete
8.29 kB
insert overwrite table internal_platform_db.dws_social_group_content_forum_hot_feed_recall_comment_score_hi_query_engine_122 partition (imp_hour = 2026060910)
with social_group_feed_view as
(
select
uin as recall_uin
, channel_id
, feed_id
, min(first_view_time) as first_view_time
, max(last_view_time) as last_view_time
, sum(forum_detail_cnt) as forum_detail_cnt
, sum(forum_detail_dtm_s) as forum_detail_dtm_s
from
internal_platform_db.dws_social_group_content_forum_hot_feed_recall_feed_view_hi_query_engine_122
where
imp_hour >= 2026060811 and imp_hour <= 2026060910
group by
uin
, channel_id
, feed_id
),
new_feed_comment_log as
(
select
t4.recall_uin
, t1.channel_id
, t1.feed_id
, t1.comment_id
, t1.p_comment_id
, t1.uin
, t1.comment_uin
, t1.p_comment_uin
, t1.author_uin
, t1.action_type
, t1.comment_type
, nvl(t5.member_role, t1.user_type) as user_type
, t1.time_stamp
, t4.first_view_time as first_view_time
from
(
select
channel_id
, feed_id
, comment_id
, p_comment_id
, uin
, comment_uin
, p_comment_uin
, author_uin
, action_type
, comment_type
, nvl(user_type, 0) as user_type
, time_stamp
from
internal_platform_db.dwd_social_group_content_forum_hot_feed_recall_comment_log_hi_query_engine_122
where
imp_hour >= 2026060811 and imp_hour <= 2026060910
) t1
join
(
select
recall_uin
, channel_id
, feed_id
, first_view_time
from
social_group_feed_view
) t4
on
t1.channel_id = t4.channel_id
and t1.feed_id = t4.feed_id
left join
(
select
uin
, channel_id
, member_role
from
internal_platform_db.dwd_all_social_group_user_slice_ds_query_engine_122
where
imp_date >= 20260607
) t5
on
t1.uin = t5.uin
and t1.channel_id = t5.channel_id
where
t1.time_stamp >= t4.first_view_time
)
select
recall_uin as uin
, channel_id
, feed_id
, comment_id
, comment_time
, normal_comment_like_score + key_author_comment_like_score + key_owner_comment_like_score
+ normal_comment_reply_score + key_author_comment_reply_score + key_owner_comment_reply_score
+ avg_normal_comment_reply_score as comment_score
, normal_comment_like_score
, key_author_comment_like_score
, key_owner_comment_like_score
, normal_comment_reply_score
, key_author_comment_reply_score
, key_owner_comment_reply_score
, avg_normal_comment_reply_score
, normal_comment_like_uv
, normal_comment_like_cnt
, key_author_comment_like_uv
, key_author_comment_like_cnt
, key_owner_comment_like_uv
, key_owner_comment_like_cnt
, normal_comment_reply_uv
, normal_comment_reply_cnt
, avg_normal_comment_reply_cnt
, key_author_comment_reply_uv
, key_author_comment_reply_cnt
, key_owner_comment_reply_uv
, key_owner_comment_reply_cnt
from
(
select
recall_uin
, channel_id
, feed_id
, comment_id
, last_comment_time as comment_time
, case
when normal_comment_like_cnt = 1 then 2
when normal_comment_like_cnt > 1 and normal_comment_like_cnt < 5 then 4
when normal_comment_like_cnt >= 5 and normal_comment_like_cnt <= 10 then 7
when normal_comment_like_cnt > 10 and normal_comment_like_cnt <= 20 then 8
when normal_comment_like_cnt > 20 and normal_comment_like_cnt <= 50 then 10
when normal_comment_like_cnt > 50 then 12
else 0
end as normal_comment_like_score
, case
when key_author_comment_like_uv = 1 then 2+2
when key_author_comment_like_uv > 1 and key_author_comment_like_uv < 5 then 4+2
when key_author_comment_like_uv >= 5 and key_author_comment_like_uv <= 10 then 7+2
when key_author_comment_like_uv > 10 and key_author_comment_like_uv <= 20 then 8+2
when key_author_comment_like_uv > 20 and key_author_comment_like_uv <= 50 then 10+2
when key_author_comment_like_uv > 50 then 12+2
else 0
end as key_author_comment_like_score
, case
when key_owner_comment_like_cnt = 1 then 2+1
when key_owner_comment_like_cnt > 1 and key_owner_comment_like_cnt < 5 then 4+1
when key_owner_comment_like_cnt >= 5 and key_owner_comment_like_cnt <= 10 then 7+1
when key_owner_comment_like_cnt > 10 and key_owner_comment_like_cnt <= 20 then 8+1
when key_owner_comment_like_cnt > 20 and key_owner_comment_like_cnt <= 50 then 10+1
when key_owner_comment_like_cnt > 50 then 12+1
else 0
end as key_owner_comment_like_score
, case
when normal_comment_reply_cnt >= 1 and normal_comment_reply_cnt < 4 then
case when normal_comment_reply_uv * 2.5 > 30 then 30 else normal_comment_reply_uv * 2.5 end
when normal_comment_reply_cnt >= 4 then
case when normal_comment_reply_uv * 2 > 30 then 30 else normal_comment_reply_uv * 2 end
else 0
end as normal_comment_reply_score
, case
when key_author_comment_reply_cnt >= 1 and key_author_comment_reply_cnt < 4 then
case when key_author_comment_reply_uv * 2.5 + 3 > 30 then 30 else key_author_comment_reply_uv * 2.5 + 3 end
when key_author_comment_reply_cnt >= 4 then
case when key_author_comment_reply_uv * 2 + 3 > 30 then 30 else key_author_comment_reply_uv * 2 + 3 end
else 0
end as key_author_comment_reply_score
, case
when key_owner_comment_reply_cnt >= 1 and key_owner_comment_reply_cnt < 4 then
case when key_owner_comment_reply_uv * 2.5 + 1 > 30 then 30 else key_owner_comment_reply_uv * 2.5 + 1 end
when key_owner_comment_reply_cnt >= 4 then
case when key_owner_comment_reply_uv * 2 + 1 > 30 then 30 else key_owner_comment_reply_uv * 2 + 1 end
else 0
end as key_owner_comment_reply_score
, case
when avg_normal_comment_reply_cnt <= 1.5 then 0
when avg_normal_comment_reply_cnt > 1.5 and avg_normal_comment_reply_cnt <= 3 then 3
when avg_normal_comment_reply_cnt > 3 then 6
else 0
end as avg_normal_comment_reply_score
, normal_comment_like_uv
, normal_comment_like_cnt
, key_author_comment_like_uv
, key_author_comment_like_cnt
, key_owner_comment_like_uv
, key_owner_comment_like_cnt
, normal_comment_reply_uv
, normal_comment_reply_cnt
, avg_normal_comment_reply_cnt
, key_author_comment_reply_uv
, key_author_comment_reply_cnt
, key_owner_comment_reply_uv
, key_owner_comment_reply_cnt
from
(
select
recall_uin
, channel_id
, feed_id
, comment_id
, max(last_comment_time) as last_comment_time
, count(distinct case when normal_comment_like_cnt > 0 then uin else null end) as normal_comment_like_uv
, sum(normal_comment_like_cnt) as normal_comment_like_cnt
, count(distinct case when key_author_comment_like_cnt > 0 then uin else null end) as key_author_comment_like_uv
, sum(key_author_comment_like_cnt) as key_author_comment_like_cnt
, count(distinct case when key_owner_comment_like_cnt > 0 then uin else null end) as key_owner_comment_like_uv
, sum(key_owner_comment_like_cnt) as key_owner_comment_like_cnt
, count(distinct case when normal_comment_reply_cnt > 0 then uin else null end) as normal_comment_reply_uv
, sum(normal_comment_reply_cnt) as normal_comment_reply_cnt
, sum(normal_comment_reply_cnt)/count(distinct case when normal_comment_reply_cnt > 0 then uin else null end) as avg_normal_comment_reply_cnt
, count(distinct case when key_author_comment_reply_cnt > 0 then uin else null end) as key_author_comment_reply_uv
, sum(key_author_comment_reply_cnt) as key_author_comment_reply_cnt
, count(distinct case when key_owner_comment_reply_cnt > 0 then uin else null end) as key_owner_comment_reply_uv
, sum(key_owner_comment_reply_cnt) as key_owner_comment_reply_cnt
from
(
select
recall_uin
, channel_id
, feed_id
, p_comment_id as comment_id
, max(time_stamp) as last_comment_time
, uin
, sum(case when action_type = 'comment_like' and user_type in (0) then 1 else 0 end) as normal_comment_like_cnt
, sum(case when action_type = 'comment_like' and uin = author_uin then 1 else 0 end) as key_author_comment_like_cnt
, sum(case when action_type = 'comment_like' and user_type in (1,2) then 1 else 0 end) as key_owner_comment_like_cnt
, sum(case when action_type = 'comment' and comment_type = 'comment_reply' and user_type in (0) and uin <> comment_uin then 1 else 0 end) normal_comment_reply_cnt
, sum(case when action_type = 'comment' and comment_type = 'comment_reply' and uin = author_uin and uin <> comment_uin then 1 else 0 end) key_author_comment_reply_cnt
, sum(case when action_type = 'comment' and comment_type = 'comment_reply' and user_type in (1,2) and uin <> comment_uin then 1 else 0 end) key_owner_comment_reply_cnt
from
new_feed_comment_log
where
action_type = 'comment_like' or (action_type = 'comment' and comment_type = 'comment_reply')
group by
recall_uin
, channel_id
, feed_id
, p_comment_id
, uin
) t
group by
recall_uin
, channel_id
, feed_id
, comment_id
) tt
) t