我在配置单元中有下表架构:
id: String
results: map <int, struct <followers: <string, array <int>>>>
样品记录:
abcd-1234-efgh-5678 {12: {"followers": {"Richard": [1, 2, 3], "Rick": [99, 10, 100]}}, 88: {"followers": {"Mina": [88], "Ray": [100000, 88, 7213, 3]}}}
如果我想获得每个结果的最小跟随者数,我使用以下查询:
SELECT result_id, follower_name, MIN(follower_count)
FROM the_table
LATERAL VIEW explode(results) results AS result_id, result
LATERAL VIEW explode(result.followers) followers AS follower_name, follower_count_list
LATERAL VIEW explode(follower_count_list) follower_count_list AS follower_count
GROUP BY result_id, follower_name;
这是正确的,如果第一列有许多跟随者,则会产生冗余值。
还有其他的使用方法吗 GROUP BY
在Map和阵列上?
暂无答案!
目前还没有任何答案,快来回答吧!