pengbo commented on a change in pull request #24286: [SPARK-27351][SQL] Wrong
outputRows estimation after AggregateEstimation wit…
URL: https://github.com/apache/spark/pull/24286#discussion_r275137777
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/AggregateEstimation.scala
##########
@@ -39,8 +39,16 @@ object AggregateEstimation {
// Multiply distinct counts of group-by columns. This is an upper bound,
which assumes
// the data contains all combinations of distinct values of group-by
columns.
var outputRows: BigInt = agg.groupingExpressions.foldLeft(BigInt(1))(
- (res, expr) => res *
-
childStats.attributeStats(expr.asInstanceOf[Attribute]).distinctCount.get)
+ (res, expr) => {
+ val columnStat =
childStats.attributeStats(expr.asInstanceOf[Attribute])
+ val distinctValue: BigInt = if (columnStat.distinctCount.get == 0 &&
Review comment:
Done.
"distinctCount.get" is to get the value from the Option. The cost seems to
be negligible, but it's better to save it by one variable.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]