You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2022/01/05 02:46:58 UTC
[iotdb] branch master updated: [IOTDB-2259] Fix Error information is incorrect when aligned timeseries Data type mismatch (#4706)
This is an automated email from the ASF dual-hosted git repository.
jackietien 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 4fd2229 [IOTDB-2259] Fix Error information is incorrect when aligned timeseries Data type mismatch (#4706)
4fd2229 is described below
commit 4fd2229a778070cf84d9b94d240f0403bc8fd411
Author: Haonan <hh...@outlook.com>
AuthorDate: Wed Jan 5 10:46:23 2022 +0800
[IOTDB-2259] Fix Error information is incorrect when aligned timeseries Data type mismatch (#4706)
---
.../{ => aligned}/IOTDBInsertAlignedValuesIT.java | 57 ++++++++++++----------
.../db/utils/datastructure/AlignedTVList.java | 14 ++++--
2 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/integration/src/test/java/org/apache/iotdb/db/integration/IOTDBInsertAlignedValuesIT.java b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IOTDBInsertAlignedValuesIT.java
similarity index 73%
rename from integration/src/test/java/org/apache/iotdb/db/integration/IOTDBInsertAlignedValuesIT.java
rename to integration/src/test/java/org/apache/iotdb/db/integration/aligned/IOTDBInsertAlignedValuesIT.java
index 7f0caa8..de8d64d 100644
--- a/integration/src/test/java/org/apache/iotdb/db/integration/IOTDBInsertAlignedValuesIT.java
+++ b/integration/src/test/java/org/apache/iotdb/db/integration/aligned/IOTDBInsertAlignedValuesIT.java
@@ -17,17 +17,17 @@
* under the License.
*/
-package org.apache.iotdb.db.integration;
+package org.apache.iotdb.db.integration.aligned;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.utils.EnvironmentUtils;
import org.apache.iotdb.itbase.category.LocalStandaloneTest;
import org.apache.iotdb.jdbc.Config;
+import org.apache.iotdb.jdbc.IoTDBSQLException;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
@@ -69,15 +69,14 @@ public class IOTDBInsertAlignedValuesIT {
}
@Test
- @Ignore // SQL of insert aligned record is not supported yet
public void testInsertAlignedValues() throws SQLException {
Statement st0 = connection.createStatement();
st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (4000, (true, 17.1))");
+ "insert into root.t1.wf01.wt01(time, status, temperature) aligned values (4000, true, 17.1)");
st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (5000, (true, 20.1))");
+ "insert into root.t1.wf01.wt01(time, status, temperature) aligned values (5000, true, 20.1)");
st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (6000, (true, 22))");
+ "insert into root.t1.wf01.wt01(time, status, temperature) aligned values (6000, true, 22)");
st0.close();
Statement st1 = connection.createStatement();
@@ -86,7 +85,7 @@ public class IOTDBInsertAlignedValuesIT {
rs1.next();
Assert.assertEquals(true, rs1.getBoolean(2));
- ResultSet rs2 = st1.executeQuery("select * from root.t1.wf01.wt01");
+ ResultSet rs2 = st1.executeQuery("select status, temperature from root.t1.wf01.wt01");
rs2.next();
Assert.assertEquals(4000, rs2.getLong(1));
Assert.assertEquals(true, rs2.getBoolean(2));
@@ -105,15 +104,12 @@ public class IOTDBInsertAlignedValuesIT {
}
@Test
- @Ignore // SQL of insert aligned record is not supported yet
public void testInsertAlignedNullableValues() throws SQLException {
Statement st0 = connection.createStatement();
st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (4000, (true, 17.1))");
- st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (5000, (true, null))");
- st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (6000, (NULL, 22))");
+ "insert into root.t1.wf01.wt01(time, status, temperature) aligned values (4000, true, 17.1)");
+ st0.execute("insert into root.t1.wf01.wt01(time, status) aligned values (5000, true)");
+ st0.execute("insert into root.t1.wf01.wt01(time, temperature) aligned values (6000, 22)");
st0.close();
Statement st1 = connection.createStatement();
@@ -122,7 +118,7 @@ public class IOTDBInsertAlignedValuesIT {
rs1.next();
Assert.assertEquals(true, rs1.getBoolean(2));
- ResultSet rs2 = st1.executeQuery("select * from root.t1.wf01.wt01");
+ ResultSet rs2 = st1.executeQuery("select status, temperature from root.t1.wf01.wt01");
rs2.next();
Assert.assertEquals(4000, rs2.getLong(1));
Assert.assertEquals(true, rs2.getBoolean(2));
@@ -141,17 +137,13 @@ public class IOTDBInsertAlignedValuesIT {
}
@Test
- @Ignore // SQL of insert aligned record is not supported yet
public void testUpdatingAlignedValues() throws SQLException {
Statement st0 = connection.createStatement();
st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (4000, (true, 17.1))");
- st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (5000, (true, null))");
- st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (5000, (NULL, 20.1))");
- st0.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values (6000, (null, 22))");
+ "insert into root.t1.wf01.wt01(time, status, temperature) aligned values (4000, true, 17.1)");
+ st0.execute("insert into root.t1.wf01.wt01(time, status) aligned values (5000, true)");
+ st0.execute("insert into root.t1.wf01.wt01(time, temperature) aligned values (5000, 20.1)");
+ st0.execute("insert into root.t1.wf01.wt01(time, temperature) aligned values (6000, 22)");
st0.close();
Statement st1 = connection.createStatement();
@@ -164,7 +156,7 @@ public class IOTDBInsertAlignedValuesIT {
rs1.next();
Assert.assertEquals(null, rs1.getObject(2));
- ResultSet rs2 = st1.executeQuery("select * from root.t1.wf01.wt01");
+ ResultSet rs2 = st1.executeQuery("select status, temperature from root.t1.wf01.wt01");
rs2.next();
Assert.assertEquals(4000, rs2.getLong(1));
Assert.assertEquals(true, rs2.getBoolean(2));
@@ -189,7 +181,7 @@ public class IOTDBInsertAlignedValuesIT {
rs3.next();
Assert.assertEquals(null, rs3.getObject(2));
- ResultSet rs4 = st1.executeQuery("select * from root.t1.wf01.wt01");
+ ResultSet rs4 = st1.executeQuery("select status, temperature from root.t1.wf01.wt01");
rs4.next();
Assert.assertEquals(4000, rs4.getLong(1));
Assert.assertEquals(true, rs4.getBoolean(2));
@@ -210,13 +202,26 @@ public class IOTDBInsertAlignedValuesIT {
@Test(expected = Exception.class)
public void testInsertWithWrongMeasurementNum1() throws SQLException {
Statement st1 = connection.createStatement();
- st1.execute("insert into root.t1.wf01.wt01(time, (status, temperature)) values(11000, 100)");
+ st1.execute(
+ "insert into root.t1.wf01.wt01(time, status, temperature) aligned values(11000, 100)");
}
@Test(expected = Exception.class)
public void testInsertWithWrongMeasurementNum2() throws SQLException {
Statement st1 = connection.createStatement();
st1.execute(
- "insert into root.t1.wf01.wt01(time, (status, temperature)) values(11000, (100, 300, 400))");
+ "insert into root.t1.wf01.wt01(time, status, temperature) aligned values(11000, 100, 300, 400)");
+ }
+
+ @Test
+ public void testInsertWithWrongType() throws SQLException {
+ try (Statement st1 = connection.createStatement()) {
+ st1.execute(
+ "CREATE ALIGNED TIMESERIES root.lz.dev.GPS(latitude INT32 encoding=PLAIN compressor=SNAPPY, longitude INT32 encoding=PLAIN compressor=SNAPPY) ");
+ st1.execute("insert into root.lz.dev.GPS(time,latitude,longitude) aligned values(1,1.3,6.7)");
+ Assert.fail();
+ } catch (IoTDBSQLException e) {
+ Assert.assertEquals(313, e.getErrorCode());
+ }
}
}
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java b/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
index 47519b5..f94ad83 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/datastructure/AlignedTVList.java
@@ -855,14 +855,20 @@ public class AlignedTVList extends TVList {
*/
public static long alignedTvListArrayMemCost(TSDataType[] types) {
long size = 0;
+ // value array mem size
+ for (TSDataType type : types) {
+ if (type != null) {
+ size += (long) PrimitiveArrayManager.ARRAY_SIZE * (long) type.getDataTypeSize();
+ }
+ }
+ // size is 0 when all types are null
+ if (size == 0) {
+ return size;
+ }
// time array mem size
size += (long) PrimitiveArrayManager.ARRAY_SIZE * 8L;
// index array mem size
size += (long) PrimitiveArrayManager.ARRAY_SIZE * 4L;
- // value array mem size
- for (TSDataType type : types) {
- size += (long) PrimitiveArrayManager.ARRAY_SIZE * (long) type.getDataTypeSize();
- }
// array headers mem size
size += NUM_BYTES_ARRAY_HEADER * (2 + types.length);
// Object references size in ArrayList