You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2020/09/01 13:24:16 UTC
[incubator-iotdb] branch master updated: [IOTDB-837]
ArrayIndexOutOfBoundsException if the measurementId size is not consistent
with the value size (#1662)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 76a9aaa [IOTDB-837] ArrayIndexOutOfBoundsException if the measurementId size is not consistent with the value size (#1662)
76a9aaa is described below
commit 76a9aaa50ea57702915f7020b8962fff01e3b185
Author: wyh-ztf <67...@users.noreply.github.com>
AuthorDate: Tue Sep 1 21:18:21 2020 +0800
[IOTDB-837] ArrayIndexOutOfBoundsException if the measurementId size is not consistent with the value size (#1662)
---
.../org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java | 9 ++++++---
server/src/test/java/org/apache/iotdb/db/qp/PlannerTest.java | 10 ++++++++++
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
index eb5bb08..36fbd4d 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/strategy/PhysicalGenerator.java
@@ -31,6 +31,7 @@ import org.apache.iotdb.db.exception.metadata.MetadataException;
import org.apache.iotdb.db.exception.query.LogicalOperatorException;
import org.apache.iotdb.db.exception.query.LogicalOptimizeException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
+import org.apache.iotdb.db.exception.runtime.SQLParserException;
import org.apache.iotdb.db.metadata.PartialPath;
import org.apache.iotdb.db.qp.constant.SQLConstant;
import org.apache.iotdb.db.qp.logical.Operator;
@@ -171,9 +172,11 @@ public class PhysicalGenerator {
case INSERT:
InsertOperator insert = (InsertOperator) operator;
paths = insert.getSelectedPaths();
- if (paths.size() != 1) {
- throw new LogicalOperatorException(
- "For Insert command, cannot specified more than one seriesPath: " + paths);
+ if (insert.getMeasurementList().length != insert.getValueList().length) {
+ throw new SQLParserException(
+ String.format(
+ "the measurementList's size %d is not consistent with the valueList's size %d",
+ insert.getMeasurementList().length, insert.getValueList().length));
}
return new InsertRowPlan(paths.get(0), insert.getTime(),
diff --git a/server/src/test/java/org/apache/iotdb/db/qp/PlannerTest.java b/server/src/test/java/org/apache/iotdb/db/qp/PlannerTest.java
index 63b17d7..64a883d 100644
--- a/server/src/test/java/org/apache/iotdb/db/qp/PlannerTest.java
+++ b/server/src/test/java/org/apache/iotdb/db/qp/PlannerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import java.util.Collections;
import org.antlr.v4.runtime.misc.ParseCancellationException;
import org.apache.iotdb.db.exception.query.QueryProcessException;
+import org.apache.iotdb.db.exception.runtime.SQLParserException;
import org.apache.iotdb.db.metadata.MManager;
import org.apache.iotdb.db.metadata.PartialPath;
import org.apache.iotdb.db.qp.logical.Operator.OperatorType;
@@ -147,6 +148,15 @@ public class PlannerTest {
String queryStatement2 = "select windDirection10min from root.national.4.5.585.9_6666.9_333.88_9";
PhysicalPlan plan13 = processor.parseSQLToPhysicalPlan(queryStatement2);
assertEquals(OperatorType.QUERY, plan13.getOperatorType());
+
+ String insertStatementException = "insert into root.vehicle.d0(timestamp,s0,s1) values(10,100)";
+ try {
+ processor.parseSQLToPhysicalPlan(insertStatementException);
+ } catch (Exception e) {
+ assertEquals(new SQLParserException(
+ "the measurementList's size 2 is not consistent with the valueList's size 1")
+ .getMessage(), e.getMessage());
+ }
}
@Test(expected = ParseCancellationException.class)