You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/10/11 08:26:26 UTC
[iotdb] 01/01: [IOTDB-4600] Fix NPE occurred when deleting data
This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch deleteDataNpe
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 1b2af9e999da50d654483910d96498ee58ac4c81
Author: HTHou <hh...@outlook.com>
AuthorDate: Tue Oct 11 16:26:12 2022 +0800
[IOTDB-4600] Fix NPE occurred when deleting data
---
.../org/apache/iotdb/db/it/IoTDBDeletionIT.java | 24 ++++++++++++++++++++++
.../planner/plan/node/write/DeleteDataNode.java | 9 +++++---
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
index 83fdafbaad..2116e6200b 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBDeletionIT.java
@@ -400,6 +400,30 @@ public class IoTDBDeletionIT {
}
}
+ @Test
+ public void testDeleteDataFromEmptySeries() throws SQLException {
+ try (Connection connection = EnvFactory.getEnv().getConnection();
+ Statement statement = connection.createStatement()) {
+ statement.execute(
+ "create timeseries root.ln.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN;");
+ statement.execute(
+ "INSERT INTO root.ln.wf01.wt01(Time,status) VALUES (2022-10-11 10:20:50,true),(2022-10-11 10:20:51,true);");
+ statement.execute(
+ "create timeseries root.sg.wf01.wt01.status with datatype=BOOLEAN,encoding=PLAIN;");
+
+ statement.execute(
+ "DELETE FROM root.ln.wf01.wt01.status,root.sg.wf01.wt01.status WHERE time >2022-10-11 10:20:50;");
+
+ try (ResultSet resultSet = statement.executeQuery("select ** from root")) {
+ int cnt = 0;
+ while (resultSet.next()) {
+ cnt++;
+ }
+ Assert.assertEquals(1, cnt);
+ }
+ }
+ }
+
@Test
public void testDelSeriesWithSpecialSymbol() throws SQLException {
try (Connection connection = EnvFactory.getEnv().getConnection();
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/DeleteDataNode.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/DeleteDataNode.java
index 7fbb066f56..219b874651 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/DeleteDataNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/DeleteDataNode.java
@@ -286,9 +286,12 @@ public class DeleteDataNode extends WritePlanNode implements WALEntryValue {
for (TRegionReplicaSet regionReplicaSet :
dataPartition.getDataRegionReplicaSet(
devicePath.getFullPath(), Collections.emptyList())) {
- regionToPatternMap
- .computeIfAbsent(regionReplicaSet, o -> new ArrayList<>())
- .addAll(pathPattern.alterPrefixPath(devicePath));
+ // regionId is null when data region of devicePath not existed
+ if (regionReplicaSet.getRegionId() != null) {
+ regionToPatternMap
+ .computeIfAbsent(regionReplicaSet, o -> new ArrayList<>())
+ .addAll(pathPattern.alterPrefixPath(devicePath));
+ }
}
}
}