获取 DataFrame 的当前分区数 [英] Get current number of partitions of a DataFrame

查看:41
本文介绍了获取 DataFrame 的当前分区数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以得到一个DataFrame的当前分区数?我检查了 DataFrame javadoc (spark 1.6) 并没有找到一个方法,或者我只是错过了它?(在 JavaRDD 的情况下,有一个 getNumPartitions() 方法.)

Is there any way to get the current number of partitions of a DataFrame? I checked the DataFrame javadoc (spark 1.6) and didn't found a method for that, or am I just missed it? (In case of JavaRDD there's a getNumPartitions() method.)

推荐答案

您需要在 DataFrame 的底层 RDD 上调用 getNumPartitions(),例如 df.rdd.getNumPartitions().对于 Scala,这是一个无参数方法:df.rdd.getNumPartitions.

You need to call getNumPartitions() on the DataFrame's underlying RDD, e.g., df.rdd.getNumPartitions(). In the case of Scala, this is a parameterless method: df.rdd.getNumPartitions.

这篇关于获取 DataFrame 的当前分区数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆