shahidki31 commented on a change in pull request #32494:
URL: https://github.com/apache/spark/pull/32494#discussion_r631574179



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/UnionEstimation.scala
##########
@@ -111,6 +111,44 @@ object UnionEstimation {
       AttributeMap.empty[ColumnStat]
     }
 
+    val attrToComputeNullCount = 
union.children.map(_.output).transpose.zipWithIndex.filter {
+      case (attrs, _) => attrs.zipWithIndex.forall {
+        case (attr, childIndex) =>
+          val attrStats = union.children(childIndex).stats.attributeStats
+          attrStats.get(attr).isDefined && attrStats(attr).nullCount.isDefined
+      }
+    }
+
+    val newAttrStats = if (attrToComputeNullCount.nonEmpty) {
+      val outputAttrStats = new ArrayBuffer[(Attribute, ColumnStat)]()
+      attrToComputeNullCount.foreach {
+        case (attrs, outputIndex) =>
+          val colWithNullStatValues = 
attrs.zipWithIndex.foldLeft[Option[BigInt]](None) {
+            case (totalNullCount, (attr, childIndex)) =>
+              val colStat = 
union.children(childIndex).stats.attributeStats(attr)
+              if (totalNullCount.isDefined) {

Review comment:
       Done.




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

Reply via email to