srowen 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_r275136453
##########
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:
I'm slightly concerned about performance here. Can you save the value of
distinctCount.get so it isn't accessed twice, or is it not actually recomputed
twice as-is?
----------------------------------------------------------------
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]