视频讲解地址:
https://www.bilibili.com/video/BV1at4y1J7Bq/?spm_id_from=333.788&vd_source=aa4fb0436f6d978af872cafb81a01178
Hive面试题系列第六题-互为好友问题
题目:根据用户好友列表user_table,求互为共同好友的人有多少对。
表结构:
- create table user_table(
-
user_id string,
-
friends string
- )
- row format delimited
- FIELDS TERMINATED BY ‘|’
- LINES TERMINATED BY ‘\n’;
用户表数据: - 1001|1002,1003,1004,1005
- 1002|1001,1007,1008,1010
- 1003|1002,1004,1006
- 1004|1005,1006,1008
- 1005|1002,1001,1004
- 1006|1002,1003,1004,1007
- 1007|1004,1010
- 1008|1001,1002,1003,1004
- 1009|1005
- 1010|1001,1003,1004,1005