对于以下两种检查数据帧是否为空的方法:
df.isEmptydf.limit(1).count == 0我看到df.isEmpty有以下实现:
def isEmpty: Boolean = withAction("isEmpty", limit(1).groupBy().count().queryExecution) { plan =>
plan.executeCollect().head.getLong(0) == 0
}
Run Code Online (Sandbox Code Playgroud)
看起来它不只是直接计数。
其背后的想法是groupBy什么?只是为了获取数据框?
为什么要queryExecution使用该计划?