我有一些记录,其中每一行都属于某些类别(数据类型 - 字符串数组)和一个单独的唯一类别列表(数据类型 - 字符串)。我需要将每一行与唯一列表匹配并为其创建标志。
Input:
------
ID Category
1 ["Physics","Math"]
2 ["Math"]
3 ["Math,"Chemistry"]
4 ["Physics","Computer"]
现在,我在本地的 excel 中拥有单独的唯一类别列表,如下所示:
Unique Category
["Physics"]
["Math"]
["Chemistry"]
["Computer"]
最终输出应如下所示:
ID Category Math_F Physics_F Computer_F Chemistry_F
1 ["Physics","Math"] 1 1 0 0
2 ["Math"] 1 0 0 0
3 ["Math,"Chemistry"] 1 0 0 1
4 ["Physics","Computer"] 0 1 1 0
有人可以帮忙查询,步骤和解释。我是 Hive 的新手。