cloud-fan commented on a change in pull request #28153: [SPARK-31384][SQL] Fix 
NPE in OptimizeSkewedJoin
URL: https://github.com/apache/spark/pull/28153#discussion_r406112995
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/QueryStageExec.scala
 ##########
 @@ -162,9 +162,11 @@ case class ShuffleQueryStageExec(
     }
   }
 
-  def mapStats: MapOutputStatistics = {
-    assert(resultOption.isDefined)
-    resultOption.get.asInstanceOf[MapOutputStatistics]
+  def mapStats: Option[MapOutputStatistics] = {
+    assert(resultOption.isDefined, "ShuffleQueryStageExec should already be 
ready")
+    val stats = resultOption.get.asInstanceOf[MapOutputStatistics]
+    // mapStats can be null when the input RDD of a plan has 0 partition
 
 Review comment:
   e.g.
   ```
   /**
    * Returns the .... If the shuffle map stage has no partition, this method 
returns None, as there is no map statistics.
    */
   def mapStats: Option[MapOutputStatistics] = {
     assert(resultOption.isDefined, "ShuffleQueryStageExec should already be 
ready")
     Option(resultOption.get.asInstanceOf[MapOutputStatistics])
   }
   ```

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

Reply via email to