maropu commented on a change in pull request #32494: URL: https://github.com/apache/spark/pull/32494#discussion_r630797948
########## File path: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/UnionEstimation.scala ########## @@ -88,9 +88,18 @@ object UnionEstimation { case (attrs, outputIndex) => val dataType = unionOutput(outputIndex).dataType val statComparator = createStatComparator(dataType) - val minMaxValue = attrs.zipWithIndex.foldLeft[(Option[Any], Option[Any])]((None, None)) { - case ((minVal, maxVal), (attr, childIndex)) => + val colStatValues = attrs.zipWithIndex + .foldLeft[(Option[Any], Option[Any], Option[BigInt])]((None, None, None)) { + case ((minVal, maxVal, totalNullCount), (attr, childIndex)) => val colStat = union.children(childIndex).stats.attributeStats(attr) + // Update null count + val nullCount = if (totalNullCount.isDefined && colStat.nullCount.isDefined) { + Some(totalNullCount.get + colStat.nullCount.get) + } else if (colStat.nullCount.isDefined) { + colStat.nullCount Review comment: If some of `colStat.nullCount`s are missing, we can update the null count in output? -- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org