HyukjinKwon commented on a change in pull request #24436: [SPARK-27539][SQL]
Fix inaccurate aggregate outputRows estimation with column containing null
values
URL: https://github.com/apache/spark/pull/24436#discussion_r287070640
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/AggregateEstimation.scala
##########
@@ -42,8 +42,8 @@ object AggregateEstimation {
(res, expr) => {
val columnStat =
childStats.attributeStats(expr.asInstanceOf[Attribute])
val distinctCount = columnStat.distinctCount.get
- val distinctValue: BigInt = if (distinctCount == 0 &&
columnStat.nullCount.get > 0) {
- 1
+ val distinctValue: BigInt = if (columnStat.nullCount.get > 0) {
+ distinctCount + 1
Review comment:
Looking into the current impl, seems we ignore `null` as distinct values:
https://github.com/apache/spark/blob/239082d9667a4fa4198bd9524d63c739df147e0e/sql/core/src/main/scala/org/apache/spark/sql/execution/command/CommandUtils.scala#L270
https://github.com/apache/spark/blob/b1857a4d7dfe17663f8adccd7825d890ae70d2a1/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/EstimationUtils.scala#L50-L51
----------------------------------------------------------------
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]