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_r406111370
 
 

 ##########
 File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/adaptive/DemoteBroadcastHashJoin.scala
 ##########
 @@ -29,11 +28,11 @@ import org.apache.spark.sql.internal.SQLConf
 case class DemoteBroadcastHashJoin(conf: SQLConf) extends Rule[LogicalPlan] {
 
   private def shouldDemote(plan: LogicalPlan): Boolean = plan match {
-    case LogicalQueryStage(_, stage: ShuffleQueryStageExec) if 
stage.resultOption.isDefined
-      && stage.resultOption.get != null =>
-      val mapOutputStatistics = 
stage.resultOption.get.asInstanceOf[MapOutputStatistics]
-      val partitionCnt = mapOutputStatistics.bytesByPartitionId.length
-      val nonZeroCnt = mapOutputStatistics.bytesByPartitionId.count(_ > 0)
+    case LogicalQueryStage(_, s: ShuffleQueryStageExec) if 
s.resultOption.isEmpty => false
+    case LogicalQueryStage(_, s: ShuffleQueryStageExec) if 
s.mapStats.isDefined =>
 
 Review comment:
   nit: we can still use one case `case LogicalQueryStage(_, s: 
ShuffleQueryStageExec) if s.resultOption.isDefined && s.mapStates.isDefined`

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