LuciferYang commented on code in PR #47931:
URL: https://github.com/apache/spark/pull/47931#discussion_r1736399383


##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala:
##########
@@ -1608,6 +1608,47 @@ class AdaptiveQueryExecSuite
     }
   }
 
+  test("SPARK-49460: NPE error in EmptyRelationExec.cleanupResources") {

Review Comment:
   nit: `NPE` already refers to `NullPointerException`, so the `error` in the 
naming is somewhat redundant.



##########
sql/core/src/test/scala/org/apache/spark/sql/execution/adaptive/AdaptiveQueryExecSuite.scala:
##########
@@ -1608,6 +1608,47 @@ class AdaptiveQueryExecSuite
     }
   }
 
+  test("SPARK-49460: NPE error in EmptyRelationExec.cleanupResources") {
+    try {

Review Comment:
   we can use 
   
   ```scala
       withTable("t1left", "t1right", "t1empty") {
         ...
       }
   ```



##########
sql/core/src/main/scala/org/apache/spark/sql/execution/EmptyRelationExec.scala:
##########
@@ -83,10 +83,13 @@ case class EmptyRelationExec(@transient logical: 
LogicalPlan) extends LeafExecNo
   }
 
   override protected[sql] def cleanupResources(): Unit = {
-    logical.foreach {
-      case LogicalQueryStage(_, physical) =>
-        physical.cleanupResources()
-      case _ =>
+    // This code path might be executed in executor where `logical` could be 
null.
+    if (logical != null) {

Review Comment:
   `if (logical != null)` is ok, but I like `Option(logical).foreach `



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