dicemy/DataClawEval huggingface dataset:
# Message Queue Topic Dimension Table internal_platform_db.dim_mq_topic_d_su (HiveSQL)

## Prompt
**Task Objective**: Read data from the previous day's partition of the input table and copy it as-is to the output table's current day partition.

**Time Variables**: The platform provides these variables for dynamic date computation:
- `${yyyymmdd}` : current day in YYYYMMDD format
- `${yyyymmdd-1}` : previous day in YYYYMMDD format
- You may also use Spark SQL built-in functions like `current_date()` and `date_sub()`.

**Input**: `internal_platform_db.dim_mq_topic_d_query_engine_001` (a partitioned table, partitioned by `dt`).

**Processing Rules**: 1) Select all data where the `dt` partition equals the previous day (use `${yyyymmdd-1}`); 2) No joins, single-table processing; 3) All fields are retained as-is, with no transformations or filtering.

**Output Requirements**: Output all non-partition columns: `business_id`, `business_name`, `cluster_set`, `tenant`, `namespaces`, `topic`, `mq_type`, `dw_appgroup`, `in_charge`, `description`, `create_time`, `modify_time`, `cluster_id`, `cluster_type`, `cluster_name`, `bg`, `category_name`, `is_filtered`, `tids`, `consumed_tids`, `unconsumed_tids`, `is_fully_consumed`, `has_unconsumed_tid`, `system_belong`; partitioned by the `dt` field.

**Write Requirements**: Use `INSERT OVERWRITE` to write to the current day partition (use `${yyyymmdd}`) of `internal_platform_db.dim_mq_topic_d_copilot_cand_query_engine_001`.

Please write the final HiveSQL to `result.sql` and execute it.

## Reference Solution
INSERT overwrite TABLE internal_platform_db.dim_mq_topic_d_copilot_query_engine_001 PARTITION (dt = '20260507')
SELECT
  business_id
  ,business_name
  ,cluster_set
  ,tenant
  ,namespaces
  ,topic
  ,mq_type
  ,dw_appgroup
  ,in_charge
  ,description
  ,create_time
  ,modify_time
  ,cluster_id
  ,cluster_type
  ,cluster_name
  ,bg
  ,category_name
  ,is_filtered
  ,tids
  ,consumed_tids
  ,unconsumed_tids
  ,is_fully_consumed
  ,has_unconsumed_tid
  ,system_belong
FROM internal_platform_db.dim_mq_topic_d_query_engine_001
where dt = '20260506'
# 将源表 internal_platform_db.app_group_product_info_sup (HiveSQL)

## Prompt
任务目标：将应用组与产品归属关系按天做历史快照，按分区全量覆盖写入目标表。

输入：internal_platform_db.app_group_product_info_query_engine_011
- 字段：username、application_group、application_group_owner、product_id、product_name、product_owner、obs_product_id、obs_product_name、obs_product_owner、department、plan_product_id、plan_product_name、plan_product_owner、application_group_numbers、application_group_owners、product_owners、obs_product_owners、plan_product_owners、bg、id

处理规则：
1. 无 Join，单表处理
2. 无过滤条件，全量读取源表所有记录
3. 无聚合操作
4. 追加派生列 dt（STRING 类型），填充当天日期字符串（格式 YYYYMMDD，如 '20260507'），置于输出字段最前

输出要求：
- 输出字段顺序：dt、username、application_group、application_group_owner、product_id、product_name、product_owner、obs_product_id、obs_product_name、obs_product_owner、department、plan_product_id、plan_product_name、plan_product_owner、application_group_numbers、application_group_owners、product_owners、obs_product_owners、plan_product_owners、bg、id
- 无需去重

写入要求：
- 目标表：internal_platform_db.app_group_product_info_history_cand_query_engine_011
- 分区字段：dt（STRING）
- 写入方式：INSERT OVERWRITE 按分区写入
- 若目标表不存在，先按 Hive 标准建表（ORC 存储、按 dt 分区），再写入

请将最终 HiveSQL 写入 result.sql 并执行。

## Reference Solution
insert overwrite TABLE internal_platform_db.app_group_product_info_history_query_engine_011 PARTITION (dt = '20260507')
SELECT
username,
application_group,
application_group_owner,
product_id,
product_name,
product_owner,
obs_product_id,
obs_product_name,
obs_product_owner,
department,
plan_product_id,
plan_product_name,
plan_product_owner,
application_group_numbers,
application_group_owners,
product_owners,
obs_product_owners,
plan_product_owners,
bg,
id
FROM internal_platform_db.app_group_product_info_query_engine_011;
# 从 internal_platform_db.dws_mq_production_featur (HiveSQL)

## Prompt
任务目标：汇总当天有生产量的 消息队列MQ topic 维度信息及近7/30/90天生产统计，落地为 topic 治理项明细表。

输入：
- 表：internal_platform_db.dws_mq_production_feature_d_increase_query_engine_013
- 分区字段：dt（STRING，格式 YYYYMMDD）
- 关键字段：business_id、business_name、topic、cluster_set、tenant、namespaces、system_belong、dw_appgroup、in_charge、description、create_time、modify_time、cluster_id、cluster_type、cluster_name、bg、category_name、total_produce_pkg_d、production_days_last_7d、total_produce_pkg_last_7d、production_days_last_30d、total_produce_pkg_last_30d、production_days_last_90d、total_produce_pkg_last_90d、is_consumed、has_consumption_days_last_7d、has_consumption_days_last_30d、has_consumption_days_last_90d

处理规则：
1. 过滤条件：dt = '20260507' AND total_produce_pkg_last_90d > 0
2. 无 Join，单表处理
3. 派生字段：
   - mq_full_topic：若 tenant 和 namespaces 均非 NULL，则拼接为 'persistent://' + tenant + '/' + namespaces + '/' + topic；否则直接取 topic
   - app_group：取自 dw_appgroup
   - bid_incharge：取自 in_charge
   - bid_description：取自 description
   - bid_create_time：取自 create_time
   - bid_modify_time：取自 modify_time
   - hitted_gov_items：固定为 NULL
   - governance_benefit_estimate：固定为 NULL

输出要求：
- 输出字段顺序：dt、business_id、business_name、topic、cluster_set、mq_full_topic、system_belong、app_group、bid_incharge、bid_description、bid_create_time、bid_modify_time、cluster_id、cluster_type、cluster_name、bg、category_name、total_produce_pkg_d、production_days_last_7d、total_produce_pkg_last_7d、production_days_last_30d、total_produce_pkg_last_30d、production_days_last_90d、total_produce_pkg_last_90d、is_consumed、has_consumption_days_last_7d、has_consumption_days_last_30d、has_consumption_days_last_90d、hitted_gov_items、governance_benefit_estimate

写入要求：
- 目标表：internal_platform_db.ads_mq_topic_governance_item_d_cand_query_engine_013
- 分区字段：dt（STRING，格式 YYYYMMDD）
- 写入方式：INSERT OVERWRITE 按分区写入
- 若目标表不存在，先按 Hive 标准建表（ORC存储、按 dt 分区），再写入

请将最终 HiveSQL 写入 result.sql 并执行。

## Reference Solution
INSERT OVERWRITE TABLE internal_platform_db.ads_mq_topic_governance_item_d_query_engine_013 PARTITION (dt = '20260507')
SELECT
  business_id,
  business_name,
  topic,
  cluster_set,
  IF ( tenant IS NOT NULL AND namespaces IS NOT NULL, CONCAT( 'persistent://', tenant, '/', namespaces, '/', topic ), topic ) AS mq_full_topic,
  system_belong,
  dw_appgroup AS app_group,
  in_charge AS bid_incharge,
  description AS bid_description,
  create_time AS bid_create_time,
  modify_time AS bid_modify_time,
  cluster_id,
  cluster_type,
  cluster_name,
  bg,
  category_name,
  total_produce_pkg_d,
  production_days_last_7d,
  total_produce_pkg_last_7d,
  production_days_last_30d,
  total_produce_pkg_last_30d,
  production_days_last_90d,
  total_produce_pkg_last_90d,
  is_consumed,
  has_consumption_days_last_7d,
  has_consumption_days_last_30d,
  has_consumption_days_last_90d,
  NULL AS hitted_gov_items,
  NULL AS governance_benefit_estimate
FROM internal_platform_db.dws_mq_production_feature_d_increase_query_engine_013
WHERE dt = '20260507'
AND total_produce_pkg_last_90d > 0
# Input Table internal_platform_db.ods_t_databus_access_topic (HiveSQL)

## Prompt
Task Objective: Cleanse the 数据总线 topic access cost raw data and aggregate it by topic dimension, excluding test topics, then write the results to a detail table.

Input: `internal_platform_db.ods_t_databus_access_topic_cost_date_d_query_engine_015`, partitioned by field `dt` (STRING, YYYYMMDD). Key fields: `systemname`, `dwproductname`, `dwappgroup`, `cityid`, `iset`, `topic`, `data_size` (BIGINT), `total_cost` (DOUBLE), `in_charge`.

Processing Rules: No joins, single-table processing. Filter condition: `dt = '20260507' AND topic <> 'test'`. Aggregation: Group by `topic`, applying `MAX` to `systemname`, `dwproductname`, `dwappgroup`, `cityid`, `iset`, `data_size`, `total_cost`, and `in_charge`. Derived column: `dt` directly takes the partition value `'20260507'`.

Output Requirements: The output field order is `dt`, `system_belong`, `category_name`, `dw_appgroup`, `city_id`, `cluster_set`, `topic`, `total_data_size_d`, `total_cost`, `in_charge`. Field mappings: `dt=dt`, `system_belong=MAX(systemname)`, `category_name=MAX(dwproductname)`, `dw_appgroup=MAX(dwappgroup)`, `city_id=MAX(cityid)`, `cluster_set=MAX(iset)`, `topic=topic`, `total_data_size_d=MAX(data_size)`, `total_cost=MAX(total_cost)`, `in_charge=MAX(in_charge)`. Data types: `dt` STRING, `system_belong` STRING, `category_name` STRING, `dw_appgroup` STRING, `city_id` STRING, `cluster_set` STRING, `topic` STRING, `total_data_size_d` BIGINT, `total_cost` DOUBLE, `in_charge` STRING.

Write Requirements: Target table `internal_platform_db.dwd_databus_topic_cost_detail_d_cand_query_engine_015`. Table comment: "数据总线 topic access cost detail table, including access cost and dimension information, performing data cleansing on the ODS layer." Partition field `dt` (STRING, YYYYMMDD). Write method: `INSERT OVERWRITE`, overwriting the partition `dt='20260507'`. If the target table does not exist, first create the table using standard Hive ORC storage format partitioned by `dt`, then write the data.

Please write the final HiveSQL to `result.sql` and execute it.

## Reference Solution
INSERT overwrite TABLE internal_platform_db.dwd_databus_topic_cost_detail_d_query_engine_015 PARTITION (dt = '20260507')
SELECT
  MAX(systemname) AS system_belong,
  MAX(dwproductname) AS category_name,
  MAX(dwappgroup) AS dw_appgroup,
  MAX(cityid) AS city_id,
  MAX(iset) AS cluster_set,
  topic,
  MAX(data_size) AS total_data_size_d,
  MAX(total_cost) AS total_cost,
  MAX(in_charge) AS in_charge
FROM
  internal_platform_db.ods_t_databus_access_topic_cost_date_d_query_engine_015
WHERE
  dt = '20260507'
  AND topic <> 'test'
GROUP BY topic
# From input table internal_platform_db.t_ed_socialbook_qq_high_v2_ta (HiveSQL)

## Prompt
Task Objective
Filter out specified `tag_id` values from the tag incremental table and write the results to the target table.

Input
- `internal_platform_db.t_ed_socialbook_qq_high_v2_tag_guid_incr_query_engine_100`

Processing Rules
1. Filter condition: `ds = 20260608` AND `tag_id NOT IN (10212021124, 10606061135, 10606061136, 10808011103)`
2. No joins, single-table processing
3. Field order: `guid`, `tag_id`, `tag_value`, `redis_sub_key`, `val_type`, `splitter1`, `splitter2`, `limit_size`, `tag_status`

Output Requirements
- Output table: `internal_platform_db.t_ed_socialbook_qq_high_v2_tag_guid_incr_filter_cand_query_engine_100`
- Output fields (9 in total, fixed order): `guid`, `tag_id`, `tag_value`, `redis_sub_key`, `val_type`, `splitter1`, `splitter2`, `limit_size`, `tag_status`
- Partition column: `ds` (BIGINT type)

Write Requirements
- Write strategy: `INSERT OVERWRITE`
- Partition value: `ds=20260608`
- Write format: ORC

Please write the final HiveSQL to `result.sql` and execute it.

## Reference Solution
insert overwrite table internal_platform_db.t_ed_socialbook_qq_high_v2_tag_guid_incr_filter_query_engine_100 partition(ds=20260608)
select 
        guid,
        tag_id,  
        tag_value,
        redis_sub_key, 
        val_type, 
        splitter1,
        splitter2, 
        limit_size, 
        tag_status
    from internal_platform_db.t_ed_socialbook_qq_high_v2_tag_guid_incr_query_engine_100
    where  ds = 20260608 and tag_id not in (10212021124, 10606061135, 10606061136, 10808011103)
# From internal_platform_db.t_mg_dws_user_tag_preset_241 (HiveSQL)

## Prompt
Task Objective: Incrementally insert new user records (`user_id`, `loss_day`) into the `ds=20260608` partition of the target table that have not appeared before.

Inputs:
- `internal_platform_db.t_mg_dws_user_tag_preset_24128_query_engine_103` (source table, containing fields such as `ds`, `user_id`, `loss_day`)
- `internal_platform_db.t_mg_dws_user_tag_user_id_once_24128_query_engine_103` (existing users table, containing previously written `user_id` values)

Processing Rules:
1. Select records from the source table `internal_platform_db.t_mg_dws_user_tag_preset_24128_query_engine_103` where `ds=20260608`
2. Use a `NOT IN` subquery to exclude `user_id` values that already exist in the existing users table `internal_platform_db.t_mg_dws_user_tag_user_id_once_24128_query_engine_103` (deduplication condition: `user_id`)
3. Extract fields: `user_id`, `loss_day`

Output Requirements:
- Output field order: `user_id`, `loss_day`
- No deduplication needed (duplicates are already filtered out via `NOT IN`)

Write Requirements:
- Target table: `internal_platform_db.t_mg_dws_user_tag_user_id_once_24128_cand_query_engine_103`
- Write method: `INSERT INTO` (append)

Please write the final HiveSQL to `result.sql` and execute it.

## Reference Solution
insert into  internal_platform_db.t_mg_dws_user_tag_user_id_once_24128_query_engine_103 (user_id, loss_day)
select user_id,loss_day
from internal_platform_db.t_mg_dws_user_tag_preset_24128_query_engine_103
where
ds = 20260608
and user_id not in (select user_id from internal_platform_db.t_mg_dws_user_tag_user_id_once_24128_query_engine_103)
# 从用户活跃日志表统计每日各渠道的活跃用户数 (HiveSQL)

## Prompt
任务目标：统计各渠道的日活跃用户数。

输入：
- internal_platform_db.dwd_user_activity_log_hi_query_engine_104（用户活跃日志表）

处理规则：
1. 过滤条件：imp_date = 20260608
2. 分组维度：channel
3. 聚合指标：COUNT(DISTINCT user_id) AS dau
4. 派生列：imp_date 固定值 20260608

输出要求：
- 字段顺序：imp_date（BIGINT，固定值20260608）、channel（STRING）、dau（BIGINT）
- 按 channel 升序排列

写入要求：
- 输出表：internal_platform_db.dws_user_daily_active_by_channel_cand_query_engine_104
- 写入方式：INSERT OVERWRITE
- 分区：ds=20260608

请将最终 HiveSQL 写入 result.sql 并执行。

## Reference Solution
insert overwrite table internal_platform_db.dws_user_daily_active_by_channel_query_engine_104 partition(ds='20260608')
select
20260608 as imp_date
, channel
, count(distinct user_id) as dau
from
internal_platform_db.dwd_user_activity_log_hi_query_engine_104
where
imp_date = 20260608
group by
channel
order by
channel
# 从事件表和全量用户表 Join 过滤出 20260608 当天最后登录用户的事件，按 sdk_id (HiveSQL)

## Prompt
任务目标：按 SDK 类型和小时统计活跃用户数。

输入：
- internal_platform_db.dws_event_tracking_ul2l6h5c_events_di_query_engine_114（事件明细表）
- internal_platform_db.dws_event_tracking_ul2l6h5c_all_user_df_query_engine_114（用户维度表）

处理规则：
- Join 条件：e.user_id = u.user_id
- 过滤条件：e.imp_date = 20260608，u.imp_date = 20260608，u.last_login_date = 20260608
- 分组维度：sdk_id、event_time_hour
- 聚合指标：COUNT(DISTINCT e.user_id) as active_users
- 去重与排序：按 sdk_id 和 hour 分组，无额外排序要求

输出要求：
- 字段顺序：imp_date（固定值 20260608，BIGINT）、id（ROW_NUMBER() OVER()）、sdk_id（STRING）、hour（STRING，来源 event_time_hour）、active_users（BIGINT）

写入要求：
- 输出表：internal_platform_db.ads_event_tracking_ul2l6h5c_user_active_hour_di_cand_query_engine_114
- 写入方式：INSERT INTO

请将最终 HiveSQL 写入 result.sql 并执行。

## Reference Solution
INSERT INTO internal_platform_db.ads_event_tracking_ul2l6h5c_user_active_hour_di_query_engine_114
SELECT
20260608 as `imp_date`
, ROW_NUMBER() OVER(ORDER BY e.`sdk_id`, e.`event_time_hour`) as `id`
, e.`sdk_id` as `sdk_id`
, e.`event_time_hour` as `hour`
, COUNT(DISTINCT e.user_id) as `active_users`
FROM
internal_platform_db.dws_event_tracking_ul2l6h5c_events_di_query_engine_114 e
JOIN
internal_platform_db.dws_event_tracking_ul2l6h5c_all_user_df_query_engine_114 u
ON
u.imp_date = 20260608
and u.user_id = e.user_id
and u.last_login_date = 20260608
WHERE
e.imp_date = 20260608
GROUP BY
e.`sdk_id`
, e.`event_time_hour`
# From input table internal_platform_db.t_app_urlsafe_cont_topweb (HiveSQL)

## Prompt
Task Objective: Extract qualifying potential risk domains from the top websites collection table and write them to the target table.

Input:
- `internal_platform_db.t_app_urlsafe_cont_topwebsites_collect_df_query_engine_125` (fields: `domain`, `site`, `ds`, `src`)

Processing Rules:
1. Filter condition: `src='transco'` AND `ds=20260608` AND `length(split(domain, '\.')[0]) > 3`
2. No joins, single-table processing
3. Row limit: take the first 2000 rows
4. Field mapping and derived columns:
   - `ds` = fixed value `20260608`
   - `type` = fixed value `'transco'`
   - `fuzzer` = fixed value `'-1'`
   - `result_domain` = fixed value `'-1'`
   - `original_domain` = the `domain` field from the input table

Output Requirements:
- Output 5 columns, in the following order: `ds`, `type`, `fuzzer`, `result_domain`, `original_domain`
- No deduplication or aggregation required

Write Requirements:
- Target table: `internal_platform_db.t_dws_urlsafe_cont_potential_risk_domain_di_cand_query_engine_125`
- Write method: upsert

Please write the final HiveSQL to `result.sql` and execute it.

## Reference Solution
INSERT OVERWRITE TABLE internal_platform_db.t_dws_urlsafe_cont_potential_risk_domain_di_query_engine_125
with topsites as
(
select domain as original_domain
from internal_platform_db.t_app_urlsafe_cont_topwebsites_collect_df_query_engine_125
where src='transco'
and ds=20260608
and length(split(domain, '\\.')[0])>3
limit 2000
)
select
20260608 as ds, 'transco' as type,'-1' as fuzzer, '-1' as result_domain, original_domain
from topsites
# 从 internal_platform_db.t_boss_v1_dict_item_hour_query_engine_130 筛选 (HiveSQL)

## Prompt
任务目标：对指定分区的字典项小时表进行记录数监控统计，输出监控结果到目标表分区。

输入：
- internal_platform_db.t_boss_v1_dict_item_hour_query_engine_130

处理规则：
1. 无 Join，单表处理
2. 过滤条件：imp_hour=2026060910
3. 分组聚合：按 dim_name='AEGIS_ALL' 和 dim_value='AEGIS_ALL' 分组
4. 聚合计算：count(1) 得到 compute_item_51323
5. 派生列：
   - imp_time = 2026060910
   - data_type = 'monitor'
   - data_id = '1::dept_om::t_boss_v1_dict_item_hour_query_engine_130'
   - check_rule_id = 51322
   - check_item_id = 51323
   - compute_value = compute_item_51323
   - compare_value = null
   - check_value = compute_item_51323

输出要求：
- 输出字段顺序：imp_time, data_type, data_id, check_rule_id, check_item_id, dim_name, dim_value, compute_value, compare_value, check_value

写入要求：
- 目标表：internal_platform_db.t_boss_v1_dict_item_hour_monitor_res_cand_query_engine_130
- 写入方式：insert overwrite
- 分区：partition (p_2026060910, p_monitor)

请将最终 HiveSQL 写入 result.sql 并执行。

## Reference Solution
INSERT OVERWRITE TABLE internal_platform_db.t_boss_v1_dict_item_hour_monitor_res_query_engine_130 PARTITION (p_2026060910='p_2026060910', p_monitor='p_monitor')
SELECT imp_time, data_type, data_id, check_rule_id, check_item_id, dim_name, dim_value, compute_value, compare_value, check_value
FROM (
  WITH temp_table_1 AS (
    SELECT 'AEGIS_ALL' AS dim_name, 'AEGIS_ALL' AS dim_value, count(1) AS compute_item_51323
    FROM internal_platform_db.t_boss_v1_dict_item_hour_query_engine_130
    WHERE imp_hour = 2026060910
  )
  SELECT
    2026060910 AS imp_time,
    'monitor' AS data_type,
    '1::dept_om::t_boss_v1_dict_item_hour' AS data_id,
    51322 AS check_rule_id,
    51323 AS check_item_id,
    dim_name,
    dim_value,
    compute_item_51323 AS compute_value,
    CAST(null AS STRING) AS compare_value,
    compute_item_51323 AS check_value
  FROM temp_table_1
) t
# Filter Chinese add-friend content from log table and write to hourly cluster table (HiveSQL)

## Prompt
### Task Objective
Filter Chinese content from the add-friend log table for the specified hour, deduplicate, and write to the hourly cluster table.

### Input
- `internal_platform_db.log_17047_query_engine_131`

### Processing Rules
1. No joins, single-table processing
2. Filter conditions:
   - `day_ = '2026-06-09 00:00:00'` AND `hour_ = '2026-06-09 14:00:00'`
   - `commfrinum_ = 0`
   - `appname_ IN ('app_hello_txt', 'app_add_contact', '')`
   - `length(content_) >= 6`
   - `scene_ IN (1, 3, 10, 13, 15)`
   - `content_` contains Chinese characters (`rlike '.*[一-龥]+.*'`)
   - Number of Chinese characters > 3 (`length(regexp_replace(content_,'[^一-龥]','')) > 3`)
   - Exclude records where `content_ = concat('我是', nickname_)` AND `nicknameupdatetime_ + 86400 * 30 < timestamp_`
3. Deduplication: `SELECT DISTINCT content_`
4. Limit: `LIMIT 1600000`

### Output Requirements
- Output field: `content_` (STRING)

### Write Requirements
- Target table: `internal_platform_db.data_team_member14_addcontent_cluster_hour_cand_query_engine_131`
- Write method: `INSERT INTO`
- Partition: `ds = '2026060914'`

Please write the final HiveSQL to `result.sql` and execute it.

## Reference Solution
INSERT INTO TABLE internal_platform_db.data_team_member14_addcontent_cluster_hour_query_engine_131 PARTITION(ds='2026060914')
select distinct content_
from internal_platform_db.log_17047_query_engine_131
where day_='2026-06-09 00:00:00' and hour_ = '2026-06-09 14:00:00'
and commfrinum_=0
and appname_ in ('app_hello_txt', 'app_add_contact', '')
and length(content_)>=6
and scene_ in (1, 3, 10, 13, 15)
and length(regexp_replace(content_,'[^一-龥]',''))>3
and content_ rlike '.*[一-龥]+.*'
and not ( content_=concat("我是", nickname_) and nicknameupdatetime_ + 86400 * 30 < timestamp_ )
limit 1600000
# 从 internal_platform_db.dwd_relationship_strength_fe (HiveSQL)

## Prompt
任务目标
基于好友关系特征数据计算关系强度推荐分数，输出每个用户对（uin, touin）的加权评分结果。

输入
- internal_platform_db.dwd_relationship_strength_features_v4_di_query_engine_138（无 Join，单表处理）

处理规则
1. 过滤条件：imp_date = 20260608，且 uin >= 10000 且 touin >= 10000
2. 特征处理：
   - 对所有分数字段使用 COALESCE(field, 0) 填充空值
   - c2c_cnt_score、common_frd_num、frd_tag_num 使用 LOG(1 + field) 变换
   - age_diff 使用 LOG(100 - age_diff) 变换
3. 加权求和公式：score = (0.0327 * log_frd_tag_num + 0.0386 * touser_id_active_layer + 0.0853 * (1 - is_same_city) + 0.0564 * c2c_score + 0.1895 * log_c2c_cnt_score + 0.2455 * socialzone_visit_score + 0.1055 * socialzone_like_score + 0.1514 * socialzone_comment_score + 0.1556 * profile_view_score + 0.1531 * profile_like_score) / 28
4. 结果字段：raw_score = ROUND(score, 4)，最终 score = 1 + ROUND(score, 4) * 10000

输出要求
- 字段顺序：imp_date（固定值 20260608）、uin、touin、score、raw_score
- imp_date 作为分区字段
- 不要求去重或聚合

写入要求
- 输出表：internal_platform_db.ads_qq_sq_frd_recommendation_result_list_df_cand_query_engine_138
- 分区：imp_date = 20260608
- 写入方式：INSERT OVERWRITE 覆盖写入该分区

请将最终 HiveSQL 写入 result.sql 并执行。

## Reference Solution
INSERT OVERWRITE TABLE internal_platform_db.ads_qq_sq_frd_recommendation_result_list_df_query_engine_138 PARTITION (imp_date = 20260608)
WITH feature_modified_v2 AS (
SELECT
 uin
, touin
, COALESCE(c2c_score, 0) AS c2c_score
, COALESCE(LOG(1 + c2c_cnt_score), 0) AS log_c2c_cnt_score
, COALESCE(socialzone_visit_score, 0) AS socialzone_visit_score
, COALESCE(socialzone_like_score, 0) AS socialzone_like_score
, COALESCE(socialzone_comment_score, 0) AS socialzone_comment_score
, COALESCE(profile_view_score, 0) AS profile_view_score
, COALESCE(profile_like_score, 0) AS profile_like_score
, COALESCE(touser_id_active_layer, 0) AS touser_id_active_layer
, COALESCE(LOG(100 - age_diff), 0) AS log_age_diff_complement
, COALESCE(LOG(1 + common_frd_num), 0) AS log_common_frd
, COALESCE(active_layer_score, 0) AS active_layer_score
, COALESCE(LOG(1 + frd_tag_num), 0) AS log_frd_tag_num
, COALESCE(is_same_city, 0) AS is_same_city
, COALESCE(is_focus_frd, 0) AS is_focus_frd
, COALESCE(comsg_score, 0) AS comsg_score
FROM
internal_platform_db.dwd_relationship_strength_features_v4_di_query_engine_138
WHERE
imp_date = 20260608
),
weighted_score_v2 AS (
SELECT
fm.uin
, fm.touin
, (0.0327 * fm.log_frd_tag_num +
0.0386 * fm.touser_id_active_layer +
0.0853 * (1 - fm.is_same_city) +
0.0564 * fm.c2c_score +
0.1895 * fm.log_c2c_cnt_score +
0.2455 * fm.socialzone_visit_score +
0.1055 * fm.socialzone_like_score +
0.1514 * fm.socialzone_comment_score +
0.1556 * fm.profile_view_score +
0.1531 * fm.profile_like_score) / 28 AS score
FROM
feature_modified_v2 fm
)
SELECT
ws.uin
, ws.touin
, 1 + (ROUND(ws.score, 4) * 10000) AS score
, ROUND(ws.score, 4) AS raw_score
FROM
weighted_score_v2 ws
WHERE
uin >= 10000
AND touin >= 10000