Datasets:
metadata
id: offline-compute_HiveSQL_hivesql_018
name: >-
Compute scores for first-level comments from view records and comment logs.
Group by recall_uin + channel_id + fe
category: offline-compute/HiveSQL
timeout_seconds: 600
modality: pure-text
engine: hivesql
Prompt
Task Objective: Compute the composite score for first-level comments newly added by recalled read users after their first post view, for content heat analysis.
Inputs:
internal_platform_db.dws_social_group_content_forum_hot_feed_recall_feed_view_hi_query_engine_122(view records, filterimp_hourwithin [2026060811, 2026060910])internal_platform_db.dwd_social_group_content_forum_hot_feed_recall_comment_log_hi_query_engine_122(comment logs, filterimp_hourwithin [2026060811, 2026060910])internal_platform_db.dwd_all_social_group_user_slice_ds_query_engine_122(user identity, filterimp_date >= 20260607)
Processing Rules:
- Build a view aggregation: From the view table, aggregate by
uin+channel_id+feed_id, extracting the first/last view time, detail page view count, and duration. - Filter comments: Join the comment log with the view aggregation on
channel_id+feed_id, keeping only records where the comment time is >= the first view time. - Enrich user identity: Left join the user table, using
member_roleas a fallback foruser_type(use the originaluser_typewhen missing). - Compute first-level comment metrics: Group by
recall_uin+channel_id+feed_id+p_comment_id(as the first-level comment ID) +uin, and compute:- Normal user like count (
action_type='comment_like'ANDuser_type=0) - Author like count (
action_type='comment_like'ANDuin=author_uin) - Channel owner like count (
action_type='comment_like'ANDuser_type in (1,2)) - Normal user reply count (
action_type='comment'ANDcomment_type='comment_reply'ANDuser_type=0ANDuin<>comment_uin) - Author reply count (
action_type='comment'ANDcomment_type='comment_reply'ANDuin=author_uinANDuin<>comment_uin) - Channel owner reply count (
action_type='comment'ANDcomment_type='comment_reply'ANDuser_type in (1,2)ANDuin<>comment_uin)
- Normal user like count (
- Aggregate by
recall_uin+channel_id+feed_id+comment_idto compute deduplicated UV and totals:- UV (count distinct of users with the behavior) and counts for each like/reply type
- Normal user average reply count (total replies / number of users who replied)
- Compute scores (tiered rules):
- Normal user like score: tiered by count (1→2, 2–4→4, 5–10→7, 11–20→8, 21–50→10, >50→12)
- Author like score: tiered by UV, then +2
- Channel owner like score: tiered by count, then +1
- Normal user reply score: when count < 4, UV2.5 (cap 30); when >= 4, UV2 (cap 30)
- Author reply score: normal user reply score + 3
- Channel owner reply score: normal user reply score + 1
- Average reply score: mean <=1.5→0, 1.5–3→3, >3→6
- Total comment score: sum of the above 7 score components
Output Requirements:
- Field order:
imp_hour,uin(i.e.,recall_uin),channel_id,feed_id,comment_id,comment_time,comment_score, and the scores, UVs, and counts for each like/reply type (20 metric fields in total) comment_timetakes the last comment time of that comment- Partition field
imp_houris fixed as2026060910
Write Requirements:
- Output table:
internal_platform_db.dws_social_group_content_forum_hot_feed_recall_comment_score_hi_cand_query_engine_122 - Write method:
INSERT OVERWRITEpartitionimp_hour=2026060910
Please write the final HiveSQL to result.sql and execute it.