This is an automated email from the ASF dual-hosted git repository.
haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new d22ef7c9aa [IOTDB-4600] Fix NPE occurred when deleting data (#7563)
d22ef7c9aa is described below
commit d22ef7c9aabd35b61784bfb73585bbca27de2f08
Author: Haonan <[email protected]>
AuthorDate: Tue Oct 11 21:44:29 2022 +0800
[IOTDB-4600] Fix NPE occurred when deleting data (#7563)
---
.../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));
+ }
}
}
}