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/13 14:45:20 UTC
[iotdb] branch master updated: [IOTDB-4565] Fix NPE of schema validation (#7586)
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 ec635e27b9 [IOTDB-4565] Fix NPE of schema validation (#7586)
ec635e27b9 is described below
commit ec635e27b905b393c64e363354b267d19ab1c267
Author: Marcos_Zyk <38...@users.noreply.github.com>
AuthorDate: Thu Oct 13 22:45:14 2022 +0800
[IOTDB-4565] Fix NPE of schema validation (#7586)
---
.../iotdb/db/mpp/plan/planner/plan/node/write/InsertRowNode.java | 7 +++++++
.../db/mpp/plan/planner/plan/node/write/InsertTabletNode.java | 8 ++++++++
2 files changed, 15 insertions(+)
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertRowNode.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertRowNode.java
index 8b4cc6fa36..5f0b82eba9 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertRowNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertRowNode.java
@@ -62,6 +62,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
public class InsertRowNode extends InsertNode implements WALEntryValue {
@@ -184,6 +185,12 @@ public class InsertRowNode extends InsertNode implements WALEntryValue {
throws QueryProcessException, MetadataException {
DeviceSchemaInfo deviceSchemaInfo =
schemaTree.searchDeviceSchemaInfo(devicePath, Arrays.asList(measurements));
+ if (deviceSchemaInfo == null) {
+ throw new PathNotExistException(
+ Arrays.stream(measurements)
+ .map(s -> devicePath.getFullPath() + s)
+ .collect(Collectors.toList()));
+ }
if (deviceSchemaInfo.isAligned() != isAligned) {
throw new AlignedTimeseriesException(
String.format(
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java
index 78dc4ed767..ba4f196ebf 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/planner/plan/node/write/InsertTabletNode.java
@@ -25,6 +25,7 @@ import org.apache.iotdb.commons.exception.MetadataException;
import org.apache.iotdb.commons.path.PartialPath;
import org.apache.iotdb.commons.utils.TestOnly;
import org.apache.iotdb.db.exception.metadata.AlignedTimeseriesException;
+import org.apache.iotdb.db.exception.metadata.PathNotExistException;
import org.apache.iotdb.db.mpp.common.schematree.DeviceSchemaInfo;
import org.apache.iotdb.db.mpp.common.schematree.ISchemaTree;
import org.apache.iotdb.db.mpp.plan.analyze.Analysis;
@@ -64,6 +65,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.stream.Collectors;
public class InsertTabletNode extends InsertNode implements WALEntryValue {
@@ -177,6 +179,12 @@ public class InsertTabletNode extends InsertNode implements WALEntryValue {
public void validateAndSetSchema(ISchemaTree schemaTree) throws MetadataException {
DeviceSchemaInfo deviceSchemaInfo =
schemaTree.searchDeviceSchemaInfo(devicePath, Arrays.asList(measurements));
+ if (deviceSchemaInfo == null) {
+ throw new PathNotExistException(
+ Arrays.stream(measurements)
+ .map(s -> devicePath.getFullPath() + s)
+ .collect(Collectors.toList()));
+ }
if (deviceSchemaInfo.isAligned() != isAligned) {
throw new AlignedTimeseriesException(
String.format(