cloud-fan commented on a change in pull request #33286:
URL: https://github.com/apache/spark/pull/33286#discussion_r670104802



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/FilterEstimation.scala
##########
@@ -926,7 +932,12 @@ case class ColumnStatsMap(originalMap: 
AttributeMap[ColumnStat]) {
         // no need to scale down since it is already down to 1 (for skewed 
distribution case)
         colStat.distinctCount
       }
-      attr -> colStat.copy(distinctCount = newNdv)
+      val newNullCount = if (colStat.nullCount.isEmpty) {
+        None
+      } else {
+        Some(colStat.nullCount.get.min(rowsAfterFilter))

Review comment:
       Shall we follow how we update ndv and consider the ratio? 
   ```
           // Update ndv based on the overall filter selectivity: scale down 
ndv if the number of rows
           // decreases; otherwise keep it unchanged.
           Some(EstimationUtils.updateNdv(oldNumRows = rowsBeforeFilter,
             newNumRows = rowsAfterFilter, oldNdv = 
oriColStat.distinctCount.get))
   ```




-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to