如何将列聚合成json数组?

时间:2018-03-16 09:04:04

标签: apache-spark apache-spark-sql spark-dataframe

示例:

这是bean的数据集,我将按产品聚合到JSON数组中。

+-------+------------------------------------------------------------------+
|product|json                                                              |
+-------+------------------------------------------------------------------+
|tv     |[{purchaser: "Roger", amount:36}]                                 |
|book   |[{purchaser: "John", amount:36}, {purchaser: "Björn", amount:61}] |
+-------+------------------------------------------------------------------+

提问:

为了在elasticsearch中存储数据,我无法转换下面的数据:

{{1}}

THX

1 个答案:

答案 0 :(得分:1)

解决方案:

JobInput