Don't use count() when you don't need to return the exact number of rows
DataFrame inputJson = sqlContext.read().json(...);
if (inputJson.takeAsList(1).size() == 0) {...}
or
if (inputJson.queryExecution.toRdd.isEmpty()) {...}if (inputJson.count() == 0) {...}def isEmpty(): Boolean = withScope {
partitions.length == 0 || take(1).length == 0
}Last updated