[英]Spark scala join each group in data frame with other reference data frame
I have the following two data frames. 我有以下两个数据框。 I want do group by on input data frame and join each group with reference data frame on date column.
我想对输入数据框进行分组,并在日期列上将每个组与参考数据框合并。
%>input.show()
sid|date |count
200|2016-04-30 18:00 | 10
100|2016-04-30 18:00 | 2
200 |2016-04-30 21:00 | 5
100|2016-04-30 21:00 | 4
%>reference.show()
id|date
1|2016-04-30 18:00
2|2016-04-30 21:00
expected output
id|sid|date |count
1|200|2016-04-30 18:00 |10
2|200|2016-04-30 21:00 |5
1|100|2016-04-30 18:00 |2
2|100|2016-04-30 21:00 |4
普通加入:
reference.join(input, Array("date"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.