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/01/04 14:04:15 UTC

[iotdb] 02/02: Add Tests

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch aligned_insert_npe
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit 5d46cce3e97dd98192933c3866b07852acccb94c
Author: HTHou <hh...@outlook.com>
AuthorDate: Tue Jan 4 22:03:24 2022 +0800

    Add Tests
---
 .../{ => aligned}/IOTDBInsertAlignedValuesIT.java  | 57 ++++++++++++----------
 1 file changed, 31 insertions(+), 26 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());
+    }
   }
 }