You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2021/09/22 03:14:31 UTC

[iotdb] 01/06: add select-into tests

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

rong pushed a commit to branch nested-operations
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit bc9c76e1efaac834569322366469ca14d710de70
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Fri Sep 17 20:01:09 2021 +0800

    add select-into tests
---
 .../iotdb/db/integration/IoTDBSelectIntoIT.java    | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java
index e42e62d..1b30344 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBSelectIntoIT.java
@@ -329,6 +329,37 @@ public class IoTDBSelectIntoIT {
   }
 
   @Test
+  public void testNestedQuery() {
+    try (Connection connection =
+            DriverManager.getConnection(
+                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+        Statement statement = connection.createStatement()) {
+      statement.execute(
+          "select s1 * sin(s1) + cos(s1), sin(s1) / s1 + s1, s1 into ${2}.n2, ${2}.n3, ${2}.n4 from root.sg.d1");
+
+      try (ResultSet resultSet = statement.executeQuery("select n2, n3, n4 from root.sg.d1.d1")) {
+        assertEquals(1 + 3, resultSet.getMetaData().getColumnCount());
+
+        for (int i = 1; i < INSERTION_SQLS.length; ++i) {
+          assertTrue(resultSet.next());
+          for (int j = 0; j < 2 + 1; ++j) {
+            double s2 = Double.parseDouble(resultSet.getString(2));
+            double s3 = Double.parseDouble(resultSet.getString(3));
+            double s4 = Double.parseDouble(resultSet.getString(4));
+            assertEquals(i * Math.sin(i) + Math.cos(i), s2, 0);
+            assertEquals(Math.sin(i) / i + i, s3, 0);
+            assertEquals(i, s4, 0);
+          }
+        }
+
+        assertFalse(resultSet.next());
+      }
+    } catch (SQLException throwable) {
+      fail(throwable.getMessage());
+    }
+  }
+
+  @Test
   public void testGroupByQuery() {
     try (Connection connection =
             DriverManager.getConnection(