我想知道如何基於另一行更新某些行。Apache Spark在RDD或基於另一行的數據集中更新一行
例如,我有一個像
Id | useraname | ratings | city
--------------------------------
1, philip, 2.0, montreal, ...
2, john, 4.0, montreal, ...
3, charles, 2.0, texas, ...
一些數據我想更新在同一個城市同一個的groupId用戶(1或2)
Id | useraname | ratings | city
--------------------------------
1, philip, 2.0, montreal, ...
1, john, 4.0, montreal, ...
3, charles, 2.0, texas, ...
我如何能實現這在我的RDD或數據集?
所以,只是爲了完整性,如果Id
是一個字符串,密集排名不會工作?
例如?
Id | useraname | ratings | city
--------------------------------
a, philip, 2.0, montreal, ...
b, john, 4.0, montreal, ...
c, charles, 2.0, texas, ...
所以結果看起來是這樣的:
grade | useraname | ratings | city
--------------------------------
a, philip, 2.0, montreal, ...
a, john, 4.0, montreal, ...
c, charles, 2.0, texas, ...
恐怕這不是分佈式,但可能在這裏如此upvote。 –
@mtoto感謝您的解決方案,但只是問如果'id'是一個字符串,密集的排名不會工作? –
這種方法沒有考慮現有的「id」列,它僅僅爲「城市」列的每個唯一值賦予唯一鍵。 – mtoto