I have a spark dataframe(Spark 2.3) and it stores a sql which has zero records. When I try to calculate the number of partitions it doesn't showing any results and tried various functions like df.rdd.getNumPartitions / df.rdd.getNumPartitions()/ df.rdd.length / df.rdd.partitions.size.
How to get number of partitions from a spark dataframe having zero or millions records?
code:
empsql = 'Select * From Employee' ## In this sql it has zero records
df = spark.sql(empsql) ##Spark is configured
df.rdd.getNumPartitions
#Using df.rdd.partitions.size got error as: AttributeError: 'RDD' object has no attribute 'partitions'