Spark: Sort records in groups?

后端 未结 4 1179
忘掉有多难
忘掉有多难 2020-12-31 11:34

I have a set of records which I need to:

1) Group by \'date\', \'city\' and \'kind\'

2) Sort every group by \'prize

In my code:

impor         


        
4条回答
  •  Happy的楠姐
    2020-12-31 12:24

    As an alternative to @gasparms solution, I think one can try a filter followed by rdd.sortyBy operation. You filter each record that meets key criteria. Pre requisite is that you need to keep track of all your keys(filter combinations). You can also build it as you traverse through records.

提交回复
热议问题