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 2020/02/26 07:38:24 UTC
[incubator-iotdb] 02/02: add previousUntilLast IT
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch groupbyfill
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
commit 3eb46083bff70ee5d0e6ffadd9112eeea5559ad6
Author: JackieTien97 <Ja...@foxmail.com>
AuthorDate: Wed Feb 26 15:38:00 2020 +0800
add previousUntilLast IT
---
.../iotdb/db/integration/IoTDBGroupByFillIT.java | 186 +++++++++++++++++++++
1 file changed, 186 insertions(+)
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByFillIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByFillIT.java
index 328d094..6efbd23 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByFillIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBGroupByFillIT.java
@@ -244,6 +244,192 @@ public class IoTDBGroupByFillIT {
}
}
+ @Test
+ public void previousUntilLastTest1() {
+ String[] retArray = new String[] {
+ "17,25",
+ "22,25",
+ "27,26",
+ "32,29",
+ "37,40",
+ "42,null",
+ "47,null",
+ };
+
+ try (Connection connection = DriverManager.
+ getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ boolean hasResultSet = statement.execute(
+ "select last_value(temperature) from "
+ + "root.ln.wf01.wt01 "
+ + "GROUP BY ([17, 48), 5ms) FILL(int32[previousUntilLast])");
+
+ Assert.assertTrue(hasResultSet);
+ int cnt;
+ try (ResultSet resultSet = statement.getResultSet()) {
+ cnt = 0;
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
+ .getString(last_value("root.ln.wf01.wt01.temperature"));
+ assertEquals(retArray[cnt], ans);
+ cnt++;
+ }
+ assertEquals(retArray.length, cnt);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void previousUntilLastTest2() {
+ try (Connection connection = DriverManager.
+ getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ statement.execute(
+ "select count(temperature) from "
+ + "root.ln.wf01.wt01 "
+ + "GROUP BY ([17, 48), 5ms) FILL(int32[previousUntilLast])");
+ } catch (IoTDBSQLException e) {
+ assertEquals("Statement format is not right: Group By Fill only support last_value function", e.getMessage());
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void previousUntilLastTest3() {
+ String[] retArray = new String[] {
+ "2,null",
+ "7,21",
+ "12,25",
+ "17,25",
+ "22,25",
+ "27,26",
+ "32,29",
+ "37,40",
+ "42,null",
+ "47,null",
+ };
+
+ try (Connection connection = DriverManager.
+ getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ boolean hasResultSet = statement.execute(
+ "select last_value(temperature) from "
+ + "root.ln.wf01.wt01 "
+ + "GROUP BY ([2, 48), 5ms) FILL(int32[previousUntilLast])");
+
+ Assert.assertTrue(hasResultSet);
+ int cnt;
+ try (ResultSet resultSet = statement.getResultSet()) {
+ cnt = 0;
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
+ .getString(last_value("root.ln.wf01.wt01.temperature"));
+ assertEquals(retArray[cnt], ans);
+ cnt++;
+ }
+ assertEquals(retArray.length, cnt);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void previousUntilLastTest4() {
+ String[] retArray = new String[] {
+ "2,null,null",
+ "7,21,11.1",
+ "12,25,33.5",
+ "17,25,33.5",
+ "22,25,33.5",
+ "27,26,33.2",
+ "32,29,44.7",
+ "37,40,33.0",
+ "42,null,null",
+ "47,null,null",
+ };
+
+ try (Connection connection = DriverManager.
+ getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ boolean hasResultSet = statement.execute(
+ "select last_value(temperature), last_value(hardware) from "
+ + "root.ln.wf01.wt01 "
+ + "GROUP BY ([2, 48), 5ms) FILL(int32[previousUntilLast], double[previousUntilLast])");
+
+ Assert.assertTrue(hasResultSet);
+ int cnt;
+ try (ResultSet resultSet = statement.getResultSet()) {
+ cnt = 0;
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
+ .getString(last_value("root.ln.wf01.wt01.temperature")) + "," +
+ resultSet.getString(last_value("root.ln.wf01.wt01.hardware"));
+ assertEquals(retArray[cnt], ans);
+ cnt++;
+ }
+ assertEquals(retArray.length, cnt);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void previousUntilLastAllTest() {
+ String[] retArray = new String[] {
+ "2,null,null",
+ "7,21,11.1",
+ "12,25,33.5",
+ "17,25,33.5",
+ "22,25,33.5",
+ "27,26,33.2",
+ "32,29,44.7",
+ "37,40,33.0",
+ "42,null,null",
+ "47,null,null",
+ };
+
+ try (Connection connection = DriverManager.
+ getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
+ Statement statement = connection.createStatement()) {
+ boolean hasResultSet = statement.execute(
+ "select last_value(temperature), last_value(hardware) from "
+ + "root.ln.wf01.wt01 "
+ + "GROUP BY ([2, 48), 5ms) FILL(ALL[previousUntilLast])");
+
+ Assert.assertTrue(hasResultSet);
+ int cnt;
+ try (ResultSet resultSet = statement.getResultSet()) {
+ cnt = 0;
+ while (resultSet.next()) {
+ String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet
+ .getString(last_value("root.ln.wf01.wt01.temperature")) + "," +
+ resultSet.getString(last_value("root.ln.wf01.wt01.hardware"));
+ assertEquals(retArray[cnt], ans);
+ cnt++;
+ }
+ assertEquals(retArray.length, cnt);
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
private void prepareData() {
try (Connection connection = DriverManager
.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root",