This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch QueryWithoutNull in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit b31ed472199c10ecab46dacab087207301f9ccfc Author: JackieTien97 <[email protected]> AuthorDate: Fri May 7 20:02:19 2021 +0800 add tests --- .../apache/iotdb/db/qp/executor/PlanExecutor.java | 86 +++++----- .../apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java | 38 ++--- .../db/integration/IoTDBWithoutAnyNullIT.java | 178 ++++++++++----------- 3 files changed, 150 insertions(+), 152 deletions(-) diff --git a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java index 4eb68ad..deef907 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/executor/PlanExecutor.java @@ -18,48 +18,6 @@ */ package org.apache.iotdb.db.qp.executor; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CANCELLED; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_NODES; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_PATHS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COLUMN; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COUNT; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CREATED_TIME; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DEVICES; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DONE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_CLASS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_NAME; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_TYPE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ITEM; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PRIVILEGE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PROGRESS; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ROLE; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_STORAGE_GROUP; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TASK_NAME; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TTL; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_USER; -import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_VALUE; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDAF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDTF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDAF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDTF; -import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_NATIVE; -import static org.apache.iotdb.db.conf.IoTDBConstant.QUERY_ID; -import static org.apache.iotdb.db.conf.IoTDBConstant.STATEMENT; -import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX; - -import java.io.File; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; import org.apache.iotdb.db.auth.AuthException; import org.apache.iotdb.db.auth.AuthorityChecker; import org.apache.iotdb.db.auth.authorizer.BasicAuthorizer; @@ -189,9 +147,53 @@ import org.apache.iotdb.tsfile.utils.Binary; import org.apache.iotdb.tsfile.utils.Pair; import org.apache.iotdb.tsfile.write.schema.IMeasurementSchema; import org.apache.iotdb.tsfile.write.writer.RestorableTsFileIOWriter; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CANCELLED; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_NODES; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CHILD_PATHS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COLUMN; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_COUNT; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_CREATED_TIME; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DEVICES; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_DONE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_CLASS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_NAME; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_FUNCTION_TYPE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ITEM; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PRIVILEGE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_PROGRESS; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_ROLE; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_STORAGE_GROUP; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TASK_NAME; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_TTL; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_USER; +import static org.apache.iotdb.db.conf.IoTDBConstant.COLUMN_VALUE; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDAF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_BUILTIN_UDTF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDAF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_EXTERNAL_UDTF; +import static org.apache.iotdb.db.conf.IoTDBConstant.FUNCTION_TYPE_NATIVE; +import static org.apache.iotdb.db.conf.IoTDBConstant.QUERY_ID; +import static org.apache.iotdb.db.conf.IoTDBConstant.STATEMENT; +import static org.apache.iotdb.tsfile.common.constant.TsFileConstant.TSFILE_SUFFIX; + public class PlanExecutor implements IPlanExecutor { private static final Logger logger = LoggerFactory.getLogger(PlanExecutor.class); diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java index 5ce5665..f38bfcd 100644 --- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java +++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java @@ -18,24 +18,6 @@ */ package org.apache.iotdb.db.qp.sql; -import static org.apache.iotdb.db.index.common.IndexConstant.PATTERN; -import static org.apache.iotdb.db.index.common.IndexConstant.THRESHOLD; -import static org.apache.iotdb.db.index.common.IndexConstant.TOP_K; -import static org.apache.iotdb.db.qp.constant.SQLConstant.TIME_PATH; -import static org.apache.iotdb.db.qp.constant.SQLConstant.TOK_KILL_QUERY; - -import java.io.File; -import java.time.ZoneId; -import java.util.ArrayList; -import java.util.Collections; -import java.util.EnumMap; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import org.antlr.v4.runtime.tree.TerminalNode; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.engine.trigger.executor.TriggerEvent; import org.apache.iotdb.db.exception.index.UnsupportedIndexTypeException; @@ -247,6 +229,26 @@ import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding; import org.apache.iotdb.tsfile.utils.Pair; import org.apache.iotdb.tsfile.utils.StringContainer; +import org.antlr.v4.runtime.tree.TerminalNode; + +import java.io.File; +import java.time.ZoneId; +import java.util.ArrayList; +import java.util.Collections; +import java.util.EnumMap; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +import static org.apache.iotdb.db.index.common.IndexConstant.PATTERN; +import static org.apache.iotdb.db.index.common.IndexConstant.THRESHOLD; +import static org.apache.iotdb.db.index.common.IndexConstant.TOP_K; +import static org.apache.iotdb.db.qp.constant.SQLConstant.TIME_PATH; +import static org.apache.iotdb.db.qp.constant.SQLConstant.TOK_KILL_QUERY; + public class IoTDBSqlVisitor extends SqlBaseBaseVisitor<Operator> { private static final String DELETE_RANGE_ERROR_MSG = diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBWithoutAnyNullIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBWithoutAnyNullIT.java index 4f0aee4..98e23c4 100644 --- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBWithoutAnyNullIT.java +++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBWithoutAnyNullIT.java @@ -18,69 +18,57 @@ */ package org.apache.iotdb.db.integration; -import static org.apache.iotdb.db.constant.TestConstant.TIMESTAMP_STR; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.Statement; import org.apache.iotdb.db.conf.IoTDBDescriptor; import org.apache.iotdb.db.utils.EnvironmentUtils; import org.apache.iotdb.jdbc.Config; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; + +import static org.apache.iotdb.db.constant.TestConstant.TIMESTAMP_STR; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + public class IoTDBWithoutAnyNullIT { private static final String[] dataSet = - new String[]{ - "SET STORAGE GROUP TO root.testWithoutAnyNull", - "CREATE TIMESERIES root.testWithoutAnyNull.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN", - "CREATE TIMESERIES root.testWithoutAnyNull.d1.s2 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN", - "CREATE TIMESERIES root.testWithoutAnyNull.d1.s3 WITH DATATYPE=DOUBLE, ENCODING=PLAIN", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " - + "values(1, 21, false, 11.1)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2) " - + "values(2, 22, true)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " - + "values(3, 23, false, 33.3)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s3) " - + "values(4, 24, 44.4)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2,s3) " - + "values(5, true, 55.5)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1) " - + "values(6, 26)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2) " - + "values(7, false)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s3) " - + "values(8, 88.8)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " - + "values(9, 29, true, 99.9)", - "flush", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " - + "values(10, 20, true, 10.0)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " - + "values(11, 21, false, 11.1)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2) " - + "values(12, 22, true)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " - + "values(13, 23, false, 33.3)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s3) " - + "values(14, 24, 44.4)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2,s3) " - + "values(15, true, 55.5)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1) " - + "values(16, 26)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2) " - + "values(17, false)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s3) " - + "values(18, 88.8)", - "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " - + "values(19, 29, true, 99.9)" + new String[] { + "SET STORAGE GROUP TO root.testWithoutAnyNull", + "CREATE TIMESERIES root.testWithoutAnyNull.d1.s1 WITH DATATYPE=INT32, ENCODING=PLAIN", + "CREATE TIMESERIES root.testWithoutAnyNull.d1.s2 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN", + "CREATE TIMESERIES root.testWithoutAnyNull.d1.s3 WITH DATATYPE=DOUBLE, ENCODING=PLAIN", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " + + "values(1, 21, false, 11.1)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2) " + "values(2, 22, true)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " + + "values(3, 23, false, 33.3)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s3) " + "values(4, 24, 44.4)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2,s3) " + "values(5, true, 55.5)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1) " + "values(6, 26)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2) " + "values(7, false)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s3) " + "values(8, 88.8)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " + "values(9, 29, true, 99.9)", + "flush", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " + + "values(10, 20, true, 10.0)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " + + "values(11, 21, false, 11.1)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2) " + "values(12, 22, true)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " + + "values(13, 23, false, 33.3)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s3) " + "values(14, 24, 44.4)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2,s3) " + "values(15, true, 55.5)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1) " + "values(16, 26)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s2) " + "values(17, false)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s3) " + "values(18, 88.8)", + "INSERT INTO root.testWithoutAnyNull.d1(timestamp,s1,s2,s3) " + "values(19, 29, true, 99.9)" }; @BeforeClass @@ -101,31 +89,34 @@ public class IoTDBWithoutAnyNullIT { @Test public void withoutAnyNullTest1() { String[] retArray1 = - new String[]{ - "1,21,false,11.1", - "3,23,false,33.3", - "9,29,true,99.9", - "10,20,true,10.0", - "11,21,false,11.1", - "13,23,false,33.3", - "19,29,true,99.9" + new String[] { + "1,21,false,11.1", + "3,23,false,33.3", + "9,29,true,99.9", + "10,20,true,10.0", + "11,21,false,11.1", + "13,23,false,33.3", + "19,29,true,99.9" }; try (Connection connection = - DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root"); + DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root"); Statement statement = connection.createStatement()) { boolean hasResultSet = - statement.execute( - "select * from root.testWithoutAnyNull.d1 WITHOUT ANY NULL"); + statement.execute("select * from root.testWithoutAnyNull.d1 WITHOUT ANY NULL"); assertTrue(hasResultSet); int cnt; try (ResultSet resultSet = statement.getResultSet()) { cnt = 0; while (resultSet.next()) { - String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s1") + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s2") + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s3"); + String ans = + resultSet.getString(TIMESTAMP_STR) + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s1") + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s2") + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s3"); assertEquals(retArray1[cnt], ans); cnt++; } @@ -140,14 +131,9 @@ public class IoTDBWithoutAnyNullIT { @Test public void withoutAnyNullTest2() { String[] retArray = - new String[]{ - "10,20,true,10.0", - "11,21,false,11.1", - "13,23,false,33.3", - "19,29,true,99.9" - }; + new String[] {"10,20,true,10.0", "11,21,false,11.1", "13,23,false,33.3", "19,29,true,99.9"}; try (Connection connection = - DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root"); + DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root"); Statement statement = connection.createStatement()) { boolean hasResultSet = statement.execute( @@ -158,10 +144,14 @@ public class IoTDBWithoutAnyNullIT { try (ResultSet resultSet = statement.getResultSet()) { cnt = 0; while (resultSet.next()) { - String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s1") + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s2") + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s3"); + String ans = + resultSet.getString(TIMESTAMP_STR) + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s1") + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s2") + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s3"); assertEquals(retArray[cnt], ans); cnt++; } @@ -176,15 +166,15 @@ public class IoTDBWithoutAnyNullIT { @Test public void withoutAnyNullTest3() { String[] retArray1 = - new String[]{ - "3,23,false,33.3", - "9,29,true,99.9", - "10,20,true,10.0", - "11,21,false,11.1", - "13,23,false,33.3" + new String[] { + "3,23,false,33.3", + "9,29,true,99.9", + "10,20,true,10.0", + "11,21,false,11.1", + "13,23,false,33.3" }; try (Connection connection = - DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root"); + DriverManager.getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root"); Statement statement = connection.createStatement()) { boolean hasResultSet = statement.execute( @@ -195,10 +185,14 @@ public class IoTDBWithoutAnyNullIT { try (ResultSet resultSet = statement.getResultSet()) { cnt = 0; while (resultSet.next()) { - String ans = resultSet.getString(TIMESTAMP_STR) + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s1") + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s2") + "," + resultSet - .getString("root.testWithoutAnyNull.d1.s3"); + String ans = + resultSet.getString(TIMESTAMP_STR) + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s1") + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s2") + + "," + + resultSet.getString("root.testWithoutAnyNull.d1.s3"); assertEquals(retArray1[cnt], ans); cnt++; } @@ -212,8 +206,8 @@ public class IoTDBWithoutAnyNullIT { private static void prepareData() { try (Connection connection = - DriverManager.getConnection( - Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root"); + DriverManager.getConnection( + Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root"); Statement statement = connection.createStatement()) { for (String sql : dataSet) {
