You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/05/23 18:10:17 UTC

[GitHub] [spark] HyukjinKwon commented on a change in pull request #24436: [SPARK-27539][SQL] Fix inaccurate aggregate outputRows estimation with column containing null values

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_r287070146
 
 

 ##########
 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:
   Hm, actually, do we need to count `null` as distinct value? It's not counted as a distinct value in SQL (`F.countDistinct` or `count(DISTINCT col)`) and Pandas (`unique()` by default) at least.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org