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/26 03:30:54 UTC
[iotdb] 04/05: add tests
This is an automated email from the ASF dual-hosted git repository.
rong pushed a commit to branch const
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 0ca09d3380b9d61e2c75db92d9b1bbf936f36e2d
Author: Steve Yurong Su <ro...@apache.org>
AuthorDate: Sun Sep 26 11:25:24 2021 +0800
add tests
---
.../db/integration/IoTDBUDTFBuiltinFunctionIT.java | 45 +++++++++++++++++++---
1 file changed, 40 insertions(+), 5 deletions(-)
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java
index 07f6491..49059c5 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBUDTFBuiltinFunctionIT.java
@@ -48,11 +48,11 @@ public class IoTDBUDTFBuiltinFunctionIT {
private static final double E = 0.0001;
private static final String[] INSERTION_SQLS = {
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (0, 0, 0, 0, 0, true, '0')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (2, 1, 1, 1, 1, false, '1')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (4, 2, 2, 2, 2, false, '2')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (6, 3, 3, 3, 3, true, '3')",
- "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6) values (8, 4, 4, 4, 4, true, '4')",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s7, s8) values (0, 0, 0, 0, 0, true, '0', 0, 0)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s7) values (2, 1, 1, 1, 1, false, '1', 1)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s7) values (4, 2, 2, 2, 2, false, '2', 2)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s8) values (6, 3, 3, 3, 3, true, '3', 3)",
+ "insert into root.sg.d1(time, s1, s2, s3, s4, s5, s6, s8) values (8, 4, 4, 4, 4, true, '4', 4)",
};
@BeforeClass
@@ -295,4 +295,39 @@ public class IoTDBUDTFBuiltinFunctionIT {
fail(throwable.getMessage());
}
}
+
+ @Test
+ public void testConstantTimeSeriesGeneratingFunctions() {
+ String[] expected = {
+ "0, 0.0, 0.0, 1024, 3.141592653589793, 2.718281828459045, ",
+ "2, 1.0, null, 1024, 3.141592653589793, 2.718281828459045, ",
+ "4, 2.0, null, 1024, 3.141592653589793, 2.718281828459045, ",
+ "6, null, 3.0, null, null, 2.718281828459045, ",
+ "8, null, 4.0, null, null, 2.718281828459045, ",
+ };
+
+ try (Connection connection =
+ DriverManager.getConnection(
+ Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement();
+ ResultSet resultSet =
+ statement.executeQuery(
+ "select s7, s8, const(s7, 'value'='1024', 'type'='INT64'), pi(s7, s7), e(s7, s8, s7, s8) from root.sg.d1")) {
+
+ assertEquals(1 + 5, resultSet.getMetaData().getColumnCount());
+
+ for (int i = 0; i < INSERTION_SQLS.length; ++i) {
+ resultSet.next();
+ StringBuilder actual = new StringBuilder();
+ for (int j = 0; j < 1 + 5; ++j) {
+ actual.append(resultSet.getString(1 + j)).append(", ");
+ }
+ assertEquals(expected[i], actual.toString());
+ }
+
+ assertFalse(resultSet.next());
+ } catch (SQLException throwable) {
+ fail(throwable.getMessage());
+ }
+ }
}