Github user gatorsmile commented on a diff in the pull request:
https://github.com/apache/spark/pull/21668#discussion_r199552346
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala
---
@@ -375,16 +375,16 @@ case class CatalogStatistics(
* Convert [[CatalogStatistics]] to [[Statistics]], and match column
stats to attributes based
* on column names.
*/
- def toPlanStats(planOutput: Seq[Attribute], cboEnabled: Boolean):
Statistics = {
- if (cboEnabled && rowCount.isDefined) {
+ def toPlanStats(planOutput: Seq[Attribute], planStatsEnabled: Boolean):
Statistics = {
+ if (planStatsEnabled && rowCount.isDefined) {
val attrStats = AttributeMap(planOutput
.flatMap(a => colStats.get(a.name).map(a -> _.toPlanStat(a.name,
a.dataType))))
// Estimate size as number of rows * row size.
val size = EstimationUtils.getOutputSize(planOutput, rowCount.get,
attrStats)
Statistics(sizeInBytes = size, rowCount = rowCount, attributeStats =
attrStats)
} else {
- // When CBO is disabled or the table doesn't have other statistics,
we apply the size-only
- // estimation strategy and only propagate sizeInBytes in statistics.
+ // When plan statistics are disabled or the table doesn't have other
statistics,
+ // we apply the size-only estimation strategy and only propagate
sizeInBytes in statistics.
Statistics(sizeInBytes = sizeInBytes)
--- End diff --
I think we should respect rowCount, if it is available, no matter whether
CBO is on or off.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]