spark3.0可以改变分区数量的算子

groupby()

底层调用的 groupByKey

可以指定分区器

sortBy()

底层调用 sortByKey()
不能指定分区器

sortByKey()

默认使用 RangePartitioner 分区器,不能指定分区器

OrderedRDDFunctions 类,如下图:

使用 RangePartitioner 分区器

repartition()

底层调用 coalesce()

coalesce()

不能指定分区器

reduceByKey()

可以指定分区器,默认使用的是 HashPartitioner 分区器

groupByKey()

底层调用 groupByKey() ,可以指定分区器


原文出处:/show_1IX4Qi9rd5y4.html