我想检查一下我们如何获取有关每个分区的信息,例如总号。以yarn集群部署方式提交Spark作业时,驱动端各分区的记录数,以便在控制台进行日志或打印。
最佳答案
我会使用内置函数。它应该尽可能高效:
import org.apache.spark.sql.functions.spark_partition_id
df.groupBy(spark_partition_id).count
关于scala - Apache Spark : Get number of records per partition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46032320/