Skip to content

Commit 5905151

Browse files
authored
fix: Avoid null exception in removeSubquery (apache#147)
In `CometScalarSubquery.removeSubquery`, we should make sure the `planId` is still in `subqueryMap` before we go to delete subquery from it. Otherwise, null exception could be thrown.
1 parent 9aa42cd commit 5905151

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎spark/src/main/java/org/apache/spark/sql/comet/CometScalarSubquery.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ public static synchronized void setSubquery(long planId, ScalarSubquery subquery
4747
}
4848

4949
public static synchronized void removeSubquery(long planId, ScalarSubquery subquery) {
50-
subqueryMap.get(planId).remove(subquery.exprId().id());
50+
if (subqueryMap.containsKey(planId)) {
51+
subqueryMap.get(planId).remove(subquery.exprId().id());
5152

52-
if (subqueryMap.get(planId).isEmpty()) {
53-
subqueryMap.remove(planId);
53+
if (subqueryMap.get(planId).isEmpty()) {
54+
subqueryMap.remove(planId);
55+
}
5456
}
5557
}
5658

0 commit comments

Comments
 (0)