What is the difference between spark.sql.shuffle.partitions and spark.default.parallelism? Ask Question

What is the difference between spark.sql.shuffle.partitions and spark.default.parallelism? Ask Question

What's the difference between spark.sql.shuffle.partitions and spark.default.parallelism?

I have tried to set both of them in SparkSQL, but the task number of the second stage is always 200.

ベストアンサー1

From the answer here, spark.sql.shuffle.partitions configures the number of partitions that are used when shuffling data for joins or aggregations.

spark.default.parallelismは、ユーザーが明示的に設定していない場合に、、などの変換によって返される s 内のデフォルトのパーティション数です。 はrawRDDに対してのみ機能し、データフレームで作業する場合は無視されることに注意してください。joinreduceByKeyparallelizespark.default.parallelismRDD

実行しているタスクが結合や集計ではなく、データフレームを操作している場合、これらを設定しても効果はありません。ただし、コード内で を呼び出すdf.repartition(numOfPartitions)(新しい に割り当てることを忘れないでください) ことで、パーティションの数を自分で設定できます。val


コード内の設定を変更するには、次のようにします。

sqlContext.setConf("spark.sql.shuffle.partitions", "300")
sqlContext.setConf("spark.default.parallelism", "300")

あるいは、ジョブをクラスターに送信するときに、次のように変更することもできますspark-submit

./bin/spark-submit --conf spark.sql.shuffle.partitions=300 --conf spark.default.parallelism=300

おすすめ記事