This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch ty/TableIT in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit ba7a48e2261f6ddf547e2ea119f4dfc7c8b87b44 Author: JackieTien97 <jackietie...@gmail.com> AuthorDate: Wed Jul 24 17:28:58 2024 +0800 partial --- .../it/query/old/IoTDBNestedQueryIT.java | 29 -- .../old/alignbydevice/IoTDBAlignByDeviceIT.java | 276 ++++++++--------- .../IoTDBAlignByDeviceWithTemplateIT.java | 280 +++++++++--------- .../IoTDBOrderByLimitOffsetAlignByDeviceIT.java | 26 +- .../scalar/IoTDBCastFunctionIT.java | 328 ++++++++++----------- .../scalar/IoTDBDiffFunctionIT.java | 133 +++++---- .../scalar/IoTDBReplaceFunctionIT.java | 41 +-- .../scalar/IoTDBRoundFunctionIT.java | 200 ++++++------- .../scalar/IoTDBSubStringFunctionIT.java | 45 +-- .../java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java | 3 +- .../plan/planner/TableOperatorGenerator.java | 14 + .../predicate/ConvertPredicateToFilterVisitor.java | 4 + .../relational/planner/ir/ExpressionRewriter.java | 6 + .../planner/ir/ExpressionTreeRewriter.java | 29 +- 14 files changed, 723 insertions(+), 691 deletions(-) diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryIT.java index b64c0f51436..4e8b1a6959b 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryIT.java @@ -39,8 +39,6 @@ import java.sql.SQLException; import java.sql.Statement; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @RunWith(IoTDBTestRunner.class) @@ -452,31 +450,4 @@ public class IoTDBNestedQueryIT { Assert.fail(e.getMessage()); } } - - @Test - public void testTimeExpressions() { - try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT); - Statement statement = connection.createStatement()) { - statement.execute("USE " + DATABASE_NAME); - String query = - "SELECT s1, time, time, -(-time), time + 1 - 1, time + s1 - s1, time + 1 - 1 FROM vehicle1 where device_id='d1'"; - try (ResultSet rs = statement.executeQuery(query)) { - for (int i = 1; i <= ITERATION_TIMES; ++i) { - assertTrue(rs.next()); - for (int j = 1; j <= 7; ++j) { - assertEquals(i, Double.parseDouble(rs.getString(j)), 0.001); - } - } - assertFalse(rs.next()); - } - - query = "SELECT time, 2 * time FROM vehicle1 where device_id='d1'"; - try (ResultSet rs = statement.executeQuery(query)) { - assertFalse(rs.next()); - } - } catch (SQLException e) { - e.printStackTrace(); - Assert.fail(e.getMessage()); - } - } } diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceIT.java index 57028e6d9ea..d2f1c32dbe1 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceIT.java @@ -35,6 +35,7 @@ import java.sql.Connection; import java.sql.Statement; import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest; +import static org.junit.Assert.fail; @RunWith(IoTDBTestRunner.class) @Category({LocalStandaloneIT.class, ClusterIT.class}) @@ -46,48 +47,48 @@ public class IoTDBAlignByDeviceIT { new String[] { "CREATE DATABASE " + DATABASE_NAME, "use " + DATABASE_NAME, - "create table vehicle(device_id STRING ID, s0 INT32 MEASUREMENT, s1 INT64 MEASUREMENT, s2 FLOAT MEASUREMENT, s3 STRING MEASUREMENT, s4 BOOLEAN MEASUREMENT);", - "insert into vehicle(Time, device_id, s0) values(1,'d0', 101)", - "insert into vehicle(Time, device_id, s0) values(2,'d0', 198)", - "insert into vehicle(Time, device_id, s0) values(100,'d0', 99)", - "insert into vehicle(Time, device_id, s0) values(101,'d0', 99)", - "insert into vehicle(Time, device_id, s0) values(102,'d0', 80)", - "insert into vehicle(Time, device_id, s0) values(103,'d0', 99)", - "insert into vehicle(Time, device_id, s0) values(104,'d0', 90)", - "insert into vehicle(Time, device_id, s0) values(105,'d0', 99)", - "insert into vehicle(Time, device_id, s0) values(106,'d0', 99)", - "insert into vehicle(Time, device_id, s0) values(2,'d0', 10000)", - "insert into vehicle(Time, device_id, s0) values(50,'d0', 10000)", - "insert into vehicle(Time, device_id, s0) values(1000,'d0', 22222)", - "insert into vehicle(Time, device_id, s1) values(1,'d0', 1101)", - "insert into vehicle(Time, device_id, s1) values(2,'d0', 198)", - "insert into vehicle(Time, device_id, s1) values(100,'d0', 199)", - "insert into vehicle(Time, device_id, s1) values(101,'d0', 199)", - "insert into vehicle(Time, device_id, s1) values(102,'d0', 180)", - "insert into vehicle(Time, device_id, s1) values(103,'d0', 199)", - "insert into vehicle(Time, device_id, s1) values(104,'d0', 190)", - "insert into vehicle(Time, device_id, s1) values(105,'d0', 199)", - "insert into vehicle(Time, device_id, s1) values(2,'d0', 40000)", - "insert into vehicle(Time, device_id, s1) values(50,'d0', 50000)", - "insert into vehicle(Time, device_id, s1) values(1000,'d0', 55555)", - "insert into vehicle(Time, device_id, s1) values(2000-01-01T08:00:00+08:00,'d0', 100)", - "insert into vehicle(Time, device_id, s2) values(1000,'d0', 55555)", - "insert into vehicle(Time, device_id, s2) values(2,'d0', 2.22)", - "insert into vehicle(Time, device_id, s2) values(3,'d0', 3.33)", - "insert into vehicle(Time, device_id, s2) values(4,'d0', 4.44)", - "insert into vehicle(Time, device_id, s2) values(102,'d0', 10.00)", - "insert into vehicle(Time, device_id, s2) values(105,'d0', 11.11)", - "insert into vehicle(Time, device_id, s2) values(1000,'d0', 1000.11)", - "insert into vehicle(Time, device_id, s3) values(60,'d0', 'aaaaa')", - "insert into vehicle(Time, device_id, s3) values(70,'d0', 'bbbbb')", - "insert into vehicle(Time, device_id, s3) values(80,'d0', 'ccccc')", - "insert into vehicle(Time, device_id, s3) values(101,'d0', 'ddddd')", - "insert into vehicle(Time, device_id, s3) values(102,'d0', 'fffff')", - "insert into vehicle(Time, device_id, s3) values(2000-01-01T08:00:00+08:00,'d0', 'good')", - "insert into vehicle(Time, device_id, s4) values(100,'d0', false)", - "insert into vehicle(Time, device_id, s4) values(100,'d0', true)", - "insert into vehicle(Time, device_id, s0) values(1,'d0', 999)", - "insert into vehicle(Time, device_id, s0) values(1000,'d0', 888)", + "create table vehicle(device_id STRING ID, s0 INT32 MEASUREMENT, s1 INT64 MEASUREMENT, s2 FLOAT MEASUREMENT, s3 STRING MEASUREMENT, s4 BOOLEAN MEASUREMENT)", + "insert into vehicle(time, device_id, s0) values(1,'d0', 101)", + "insert into vehicle(time, device_id, s0) values(2,'d0', 198)", + "insert into vehicle(time, device_id, s0) values(100,'d0', 99)", + "insert into vehicle(time, device_id, s0) values(101,'d0', 99)", + "insert into vehicle(time, device_id, s0) values(102,'d0', 80)", + "insert into vehicle(time, device_id, s0) values(103,'d0', 99)", + "insert into vehicle(time, device_id, s0) values(104,'d0', 90)", + "insert into vehicle(time, device_id, s0) values(105,'d0', 99)", + "insert into vehicle(time, device_id, s0) values(106,'d0', 99)", + "insert into vehicle(time, device_id, s0) values(2,'d0', 10000)", + "insert into vehicle(time, device_id, s0) values(50,'d0', 10000)", + "insert into vehicle(time, device_id, s0) values(1000,'d0', 22222)", + "insert into vehicle(time, device_id, s1) values(1,'d0', 1101)", + "insert into vehicle(time, device_id, s1) values(2,'d0', 198)", + "insert into vehicle(time, device_id, s1) values(100,'d0', 199)", + "insert into vehicle(time, device_id, s1) values(101,'d0', 199)", + "insert into vehicle(time, device_id, s1) values(102,'d0', 180)", + "insert into vehicle(time, device_id, s1) values(103,'d0', 199)", + "insert into vehicle(time, device_id, s1) values(104,'d0', 190)", + "insert into vehicle(time, device_id, s1) values(105,'d0', 199)", + "insert into vehicle(time, device_id, s1) values(2,'d0', 40000)", + "insert into vehicle(time, device_id, s1) values(50,'d0', 50000)", + "insert into vehicle(time, device_id, s1) values(1000,'d0', 55555)", + "insert into vehicle(time, device_id, s1) values(2000-01-01T00:00:00+08:00,'d0', 100)", + "insert into vehicle(time, device_id, s2) values(1000,'d0', 55555)", + "insert into vehicle(time, device_id, s2) values(2,'d0', 2.22)", + "insert into vehicle(time, device_id, s2) values(3,'d0', 3.33)", + "insert into vehicle(time, device_id, s2) values(4,'d0', 4.44)", + "insert into vehicle(time, device_id, s2) values(102,'d0', 10.00)", + "insert into vehicle(time, device_id, s2) values(105,'d0', 11.11)", + "insert into vehicle(time, device_id, s2) values(1000,'d0', 1000.11)", + "insert into vehicle(time, device_id, s3) values(60,'d0', 'aaaaa')", + "insert into vehicle(time, device_id, s3) values(70,'d0', 'bbbbb')", + "insert into vehicle(time, device_id, s3) values(80,'d0', 'ccccc')", + "insert into vehicle(time, device_id, s3) values(101,'d0', 'ddddd')", + "insert into vehicle(time, device_id, s3) values(102,'d0', 'fffff')", + "insert into vehicle(time, device_id, s3) values(2000-01-01T00:00:00+08:00,'d0', 'good')", + "insert into vehicle(time, device_id, s4) values(100,'d0', false)", + "insert into vehicle(time, device_id, s4) values(100,'d0', true)", + "insert into vehicle(time, device_id, s0) values(1,'d0', 999)", + "insert into vehicle(time, device_id, s0) values(1000,'d0', 888)", }; @BeforeClass @@ -110,6 +111,7 @@ public class IoTDBAlignByDeviceIT { } } catch (Exception e) { e.printStackTrace(); + fail(e.getMessage()); } } @@ -118,25 +120,25 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s1", "s2", "s3", "s4"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d0,101,1101,null,null,null,", - "1997-01-01T08:00:00.002Z,d0,10000,40000,2.22,null,null,", - "1997-01-01T08:00:00.003Z,d0,null,null,3.33,null,null,", - "1997-01-01T08:00:00.004Z,d0,null,null,4.44,null,null,", - "1997-01-01T08:00:00.050Z,d0,10000,50000,null,null,null,", - "1997-01-01T08:00:00.060Z,d0,null,null,null,aaaaa,null,", - "1997-01-01T08:00:00.070Z,d0,null,null,null,bbbbb,null,", - "1997-01-01T08:00:00.080Z,d0,null,null,null,ccccc,null,", - "1997-01-01T08:00:00.100Z,d0,99,199,null,null,true,", - "1997-01-01T08:00:00.101Z,d0,99,199,null,ddddd,null,", - "1997-01-01T08:00:00.102Z,d0,80,180,10.0,fffff,null,", - "1997-01-01T08:00:00.103Z,d0,99,199,null,null,null,", - "1997-01-01T08:00:00.104Z,d0,90,190,null,null,null,", - "1997-01-01T08:00:00.105Z,d0,99,199,11.11,null,null,", - "1997-01-01T08:00:00.106Z,d0,99,null,null,null,null,", - "1997-01-01T08:00:01.000Z,d0,22222,55555,1000.11,null,null,", + "1970-01-01T00:00:00.001Z,d0,101,1101,null,null,null,", + "1970-01-01T00:00:00.002Z,d0,10000,40000,2.22,null,null,", + "1970-01-01T00:00:00.003Z,d0,null,null,3.33,null,null,", + "1970-01-01T00:00:00.004Z,d0,null,null,4.44,null,null,", + "1970-01-01T00:00:00.050Z,d0,10000,50000,null,null,null,", + "1970-01-01T00:00:00.060Z,d0,null,null,null,aaaaa,null,", + "1970-01-01T00:00:00.070Z,d0,null,null,null,bbbbb,null,", + "1970-01-01T00:00:00.080Z,d0,null,null,null,ccccc,null,", + "1970-01-01T00:00:00.100Z,d0,99,199,null,null,true,", + "1970-01-01T00:00:00.101Z,d0,99,199,null,ddddd,null,", + "1970-01-01T00:00:00.102Z,d0,80,180,10.0,fffff,null,", + "1970-01-01T00:00:00.103Z,d0,99,199,null,null,null,", + "1970-01-01T00:00:00.104Z,d0,90,190,null,null,null,", + "1970-01-01T00:00:00.105Z,d0,99,199,11.11,null,null,", + "1970-01-01T00:00:00.106Z,d0,99,null,null,null,null,", + "1970-01-01T00:00:01.000Z,d0,22222,55555,1000.11,null,null,", "2000-01-01T00:00:00.000Z,d0,null,100,null,good,null,", - "1997-01-01T08:00:00.001Z,d1,999,null,null,null,null,", - "1997-01-01T08:00:01.000Z,d1,888,null,null,null,null,", + "1970-01-01T00:00:00.001Z,d1,999,null,null,null,null,", + "1970-01-01T00:00:01.000Z,d1,888,null,null,null,null,", }; tableResultSetEqualTest( "select * from vehicle order by device_id", expectedHeader, retArray, DATABASE_NAME); @@ -148,14 +150,14 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s1", "s2", "s3", "s4"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,999,null,null,null,null,", - "1997-01-01T08:00:00.002Z,d0,10000,40000,2.22,null,null,", - "1997-01-01T08:00:00.003Z,d0,null,null,3.33,null,null,", - "1997-01-01T08:00:00.004Z,d0,null,null,4.44,null,null,", - "1997-01-01T08:00:00.050Z,d0,10000,50000,null,null,null,", + "1970-01-01T00:00:00.001Z,d1,999,null,null,null,null,", + "1970-01-01T00:00:00.002Z,d0,10000,40000,2.22,null,null,", + "1970-01-01T00:00:00.003Z,d0,null,null,3.33,null,null,", + "1970-01-01T00:00:00.004Z,d0,null,null,4.44,null,null,", + "1970-01-01T00:00:00.050Z,d0,10000,50000,null,null,null,", }; tableResultSetEqualTest( - "select * from vehicle order by Time asc, device_id offset 1 limit 5", + "select * from vehicle order by time asc, device_id offset 1 limit 5", expectedHeader, retArray, DATABASE_NAME); @@ -167,14 +169,14 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s1", "s2", "s3", "s4"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,999,null,null,null,null,", + "1970-01-01T00:00:00.001Z,d1,999,null,null,null,null,", "2000-01-01T00:00:00.000Z,d0,null,100,null,good,null,", - "1997-01-01T08:00:01.000Z,d0,22222,55555,1000.11,null,null,", - "1997-01-01T08:00:00.106Z,d0,99,null,null,null,null,", - "1997-01-01T08:00:00.105Z,d0,99,199,11.11,null,null,", + "1970-01-01T00:00:01.000Z,d0,22222,55555,1000.11,null,null,", + "1970-01-01T00:00:00.106Z,d0,99,null,null,null,null,", + "1970-01-01T00:00:00.105Z,d0,99,199,11.11,null,null,", }; tableResultSetEqualTest( - "select * from vehicle order by device_id desc, Time desc offset 1 limit 5", + "select * from vehicle order by device_id desc, time desc offset 1 limit 5", expectedHeader, retArray, DATABASE_NAME); @@ -185,20 +187,20 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s0", "s1"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d0,101,101,1101,", - "1997-01-01T08:00:00.002Z,d0,101,10000,40000,", - "1997-01-01T08:00:00.050Z,d0,10000,10000,50000,", - "1997-01-01T08:00:00.100Z,d0,99,99,199,", - "1997-01-01T08:00:00.101Z,d0,99,99,199,", - "1997-01-01T08:00:00.102Z,d0,80,80,180,", - "1997-01-01T08:00:00.103Z,d0,99,99,199,", - "1997-01-01T08:00:00.104Z,d0,90,90,190,", - "1997-01-01T08:00:00.105Z,d0,99,99,199,", - "1997-01-01T08:00:00.106Z,d0,99,99,null,", - "1997-01-01T08:00:01.000Z,d0,22222,22222,55555,", + "1970-01-01T00:00:00.001Z,d0,101,101,1101,", + "1970-01-01T00:00:00.002Z,d0,101,10000,40000,", + "1970-01-01T00:00:00.050Z,d0,10000,10000,50000,", + "1970-01-01T00:00:00.100Z,d0,99,99,199,", + "1970-01-01T00:00:00.101Z,d0,99,99,199,", + "1970-01-01T00:00:00.102Z,d0,80,80,180,", + "1970-01-01T00:00:00.103Z,d0,99,99,199,", + "1970-01-01T00:00:00.104Z,d0,90,90,190,", + "1970-01-01T00:00:00.105Z,d0,99,99,199,", + "1970-01-01T00:00:00.106Z,d0,99,99,null,", + "1970-01-01T00:00:01.000Z,d0,22222,22222,55555,", "2000-01-01T00:00:00.000Z,d0,null,null,100,", - "1997-01-01T08:00:00.001Z,d1,999,999,null,", - "1997-01-01T08:00:01.000Z,d1,888,888,null,", + "1970-01-01T00:00:00.001Z,d1,999,999,null,", + "1970-01-01T00:00:01.000Z,d1,888,888,null,", }; tableResultSetEqualTest( "select time, device_id, s0,s0,s1 from vehicle where device_id = 'd0' or device_id = 'd1' order by device_id", @@ -212,16 +214,16 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s0", "s1"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.002Z,d0,101,10000,40000,", - "1997-01-01T08:00:00.050Z,d0,10000,10000,50000,", - "1997-01-01T08:00:00.100Z,d0,99,99,199,", - "1997-01-01T08:00:00.101Z,d0,99,99,199,", - "1997-01-01T08:00:00.102Z,d0,80,80,180,", - "1997-01-01T08:00:00.103Z,d0,99,99,199,", - "1997-01-01T08:00:00.104Z,d0,90,90,190,", - "1997-01-01T08:00:00.105Z,d0,99,99,199,", - "1997-01-01T08:00:00.106Z,d0,99,99,null,", - "1997-01-01T08:00:01.000Z,d0,22222,22222,55555,", + "1970-01-01T00:00:00.002Z,d0,101,10000,40000,", + "1970-01-01T00:00:00.050Z,d0,10000,10000,50000,", + "1970-01-01T00:00:00.100Z,d0,99,99,199,", + "1970-01-01T00:00:00.101Z,d0,99,99,199,", + "1970-01-01T00:00:00.102Z,d0,80,80,180,", + "1970-01-01T00:00:00.103Z,d0,99,99,199,", + "1970-01-01T00:00:00.104Z,d0,90,90,190,", + "1970-01-01T00:00:00.105Z,d0,99,99,199,", + "1970-01-01T00:00:00.106Z,d0,99,99,null,", + "1970-01-01T00:00:01.000Z,d0,22222,22222,55555,", }; tableResultSetEqualTest( "select time, device_id, s0,s0,s1 from vehicle order by device_id offset 1 limit 10", @@ -236,12 +238,12 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s1", "s2", "s3", "s4"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.100Z,d0,99,199,null,null,true,", - "1997-01-01T08:00:00.101Z,d0,99,199,null,ddddd,null,", - "1997-01-01T08:00:00.102Z,d0,80,180,10.0,fffff,null,", - "1997-01-01T08:00:00.103Z,d0,99,199,null,null,null,", - "1997-01-01T08:00:00.104Z,d0,90,190,null,null,null,", - "1997-01-01T08:00:00.105Z,d0,99,199,11.11,null,null,", + "1970-01-01T00:00:00.100Z,d0,99,199,null,null,true,", + "1970-01-01T00:00:00.101Z,d0,99,199,null,ddddd,null,", + "1970-01-01T00:00:00.102Z,d0,80,180,10.0,fffff,null,", + "1970-01-01T00:00:00.103Z,d0,99,199,null,null,null,", + "1970-01-01T00:00:00.104Z,d0,90,190,null,null,null,", + "1970-01-01T00:00:00.105Z,d0,99,199,11.11,null,null,", }; tableResultSetEqualTest( "select * from vehicle where s0 > 0 AND s1 < 200 order by device_id", @@ -256,12 +258,12 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.100Z,d0,99,", - "1997-01-01T08:00:00.101Z,d0,99,", - "1997-01-01T08:00:00.102Z,d0,80,", - "1997-01-01T08:00:00.103Z,d0,99,", - "1997-01-01T08:00:00.104Z,d0,90,", - "1997-01-01T08:00:00.105Z,d0,99,", + "1970-01-01T00:00:00.100Z,d0,99,", + "1970-01-01T00:00:00.101Z,d0,99,", + "1970-01-01T00:00:00.102Z,d0,80,", + "1970-01-01T00:00:00.103Z,d0,99,", + "1970-01-01T00:00:00.104Z,d0,90,", + "1970-01-01T00:00:00.105Z,d0,99,", "2000-01-01T00:00:00.000Z,d0,null", }; tableResultSetEqualTest( @@ -277,7 +279,7 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.105Z,d0,99,", + "1970-01-01T00:00:00.105Z,d0,99,", }; tableResultSetEqualTest( "select time, device_id, s0 from root.vehicle.d0 where s1 < 200 and s2 > 10 order by device_id", @@ -336,7 +338,7 @@ public class IoTDBAlignByDeviceIT { // } // // @Test - // public void groupByTimeTest() { + // public void groupBytimeTest() { // String[] retArray = // new String[] { // "2,root.vehicle.d0,1,1,3,0,0,", @@ -357,9 +359,9 @@ public class IoTDBAlignByDeviceIT { // List<Integer> actualIndexToExpectedIndexList = // checkHeader( // resultSetMetaData, - // "Time,Device,count(s0),count(s1),count(s2),count(s3),count(s4)", + // "time,Device,count(s0),count(s1),count(s2),count(s3),count(s4)", // new int[] { - // Types.TIMESTAMP, + // Types.tIMESTAMP, // Types.VARCHAR, // Types.BIGINT, // Types.BIGINT, @@ -391,7 +393,7 @@ public class IoTDBAlignByDeviceIT { // } // // @Test - // public void groupByTimeWithValueFilterTest() { + // public void groupBytimeWithValueFilterTest() { // String[] retArray = // new String[] { // "2,root.vehicle.d0,2,", "102,root.vehicle.d0,1", @@ -408,9 +410,9 @@ public class IoTDBAlignByDeviceIT { // List<Integer> actualIndexToExpectedIndexList = // checkHeader( // resultSetMetaData, - // "Time,Device,count(s2)", + // "time,Device,count(s2)", // new int[] { - // Types.TIMESTAMP, Types.VARCHAR, Types.BIGINT, + // Types.tIMESTAMP, Types.VARCHAR, Types.BIGINT, // }); // // int cnt = 0; @@ -442,11 +444,11 @@ public class IoTDBAlignByDeviceIT { new String[] {"time", "device_id", "s0", "s0", "s1", "s0", "s1", "s2", "s3", "s4"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d0,101,101,1101,101,1101,null,null,null,", - "1997-01-01T08:00:00.002Z,d0,10000,10000,40000,10000,40000,2.22,null,null,", - "1997-01-01T08:00:00.003Z,d0,null,null,null,null,null,3.33,null,null,", - "1997-01-01T08:00:00.004Z,d0,null,null,null,null,null,4.44,null,null,", - "1997-01-01T08:00:00.001Z,d1,999,999,null,999,null,null,null,null,", + "1970-01-01T00:00:00.001Z,d0,101,101,1101,101,1101,null,null,null,", + "1970-01-01T00:00:00.002Z,d0,10000,10000,40000,10000,40000,2.22,null,null,", + "1970-01-01T00:00:00.003Z,d0,null,null,null,null,null,3.33,null,null,", + "1970-01-01T00:00:00.004Z,d0,null,null,null,null,null,4.44,null,null,", + "1970-01-01T00:00:00.001Z,d1,999,999,null,999,null,null,null,null,", }; tableResultSetEqualTest( "select * from vehicle where time < 20 and (device_id='d0' or device_id='d1') order by device_id", @@ -460,25 +462,25 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s1", "s2", "s3", "s4"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d0,101,1101,null,null,null,", - "1997-01-01T08:00:00.002Z,d0,10000,40000,2.22,null,null,", - "1997-01-01T08:00:00.003Z,d0,null,null,3.33,null,null,", - "1997-01-01T08:00:00.004Z,d0,null,null,4.44,null,null,", - "1997-01-01T08:00:00.050Z,d0,10000,50000,null,null,null,", - "1997-01-01T08:00:00.060Z,d0,null,null,null,aaaaa,null,", - "1997-01-01T08:00:00.070Z,d0,null,null,null,bbbbb,null,", - "1997-01-01T08:00:00.080Z,d0,null,null,null,ccccc,null,", - "1997-01-01T08:00:00.100Z,d0,99,199,null,null,true,", - "1997-01-01T08:00:00.101Z,d0,99,199,null,ddddd,null,", - "1997-01-01T08:00:00.102Z,d0,80,180,10.0,fffff,null,", - "1997-01-01T08:00:00.103Z,d0,99,199,null,null,null,", - "1997-01-01T08:00:00.104Z,d0,90,190,null,null,null,", - "1997-01-01T08:00:00.105Z,d0,99,199,11.11,null,null,", - "1997-01-01T08:00:00.106Z,d0,99,null,null,null,null,", - "1997-01-01T08:00:01.000Z,d0,22222,55555,1000.11,null,null,", + "1970-01-01T00:00:00.001Z,d0,101,1101,null,null,null,", + "1970-01-01T00:00:00.002Z,d0,10000,40000,2.22,null,null,", + "1970-01-01T00:00:00.003Z,d0,null,null,3.33,null,null,", + "1970-01-01T00:00:00.004Z,d0,null,null,4.44,null,null,", + "1970-01-01T00:00:00.050Z,d0,10000,50000,null,null,null,", + "1970-01-01T00:00:00.060Z,d0,null,null,null,aaaaa,null,", + "1970-01-01T00:00:00.070Z,d0,null,null,null,bbbbb,null,", + "1970-01-01T00:00:00.080Z,d0,null,null,null,ccccc,null,", + "1970-01-01T00:00:00.100Z,d0,99,199,null,null,true,", + "1970-01-01T00:00:00.101Z,d0,99,199,null,ddddd,null,", + "1970-01-01T00:00:00.102Z,d0,80,180,10.0,fffff,null,", + "1970-01-01T00:00:00.103Z,d0,99,199,null,null,null,", + "1970-01-01T00:00:00.104Z,d0,90,190,null,null,null,", + "1970-01-01T00:00:00.105Z,d0,99,199,11.11,null,null,", + "1970-01-01T00:00:00.106Z,d0,99,null,null,null,null,", + "1970-01-01T00:00:01.000Z,d0,22222,55555,1000.11,null,null,", "2000-01-01T00:00:00.000Z,d0,null,100,null,good,null,", - "1997-01-01T08:00:00.001Z,d1,999,null,null,null,null,", - "1997-01-01T08:00:01.000Z,d1,888,null,null,null,null,", + "1970-01-01T00:00:00.001Z,d1,999,null,null,null,null,", + "1970-01-01T00:00:01.000Z,d1,888,null,null,null,null,", }; tableResultSetEqualTest( "select * from vehicle where device_id like 'd%' order by device_id", @@ -491,7 +493,7 @@ public class IoTDBAlignByDeviceIT { String[] expectedHeader = new String[] {"time", "device_id", "s0", "s1", "s2", "s3", "s4"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d0,101,1101,null,null,null,", + "1970-01-01T00:00:00.001Z,d0,101,1101,null,null,null,", }; tableResultSetEqualTest( "select * from vehicle where s1=1101 order by device_id", diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateIT.java index 9d1217b466d..5a61cdf49c4 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceWithTemplateIT.java @@ -26,7 +26,6 @@ import org.apache.iotdb.itbase.env.BaseEnv; import org.junit.AfterClass; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; @@ -41,7 +40,6 @@ import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -@Ignore @RunWith(IoTDBTestRunner.class) @Category({LocalStandaloneIT.class, ClusterIT.class}) public class IoTDBAlignByDeviceWithTemplateIT { @@ -51,7 +49,7 @@ public class IoTDBAlignByDeviceWithTemplateIT { new String[] { "CREATE database " + DATABASE_NAME, "use " + DATABASE_NAME, - "create table table1(device_id STRING ID, s1 FLOAT MEASUREMENT, s2 BOOLEAN MEASUREMENT, s3 INT32 MEASUREMENT);", + "create table table1(device_id STRING ID, s1 FLOAT MEASUREMENT, s2 BOOLEAN MEASUREMENT, s3 INT32 MEASUREMENT)", "INSERT INTO table1(Time, device_id, s1, s2, s3) VALUES (1,'d1', 1.1, false, 1), (2, 'd1', 2.2, false, 2), (1,'d2', 11.1, false, 11), (2,'d2', 22.2, false, 22), (1,'d3', 111.1, true, null), (4,'d3', 444.4, true, 44), (1,'d4', 1111.1, true, 1111), (5,'d4', 5555.5, false, 5555)", }; @@ -72,17 +70,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] expectedHeader = new String[] {"time", "device_id", "s3", "s1", "s2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,1,1.1,false,", - "1997-01-01T08:00:00.002Z,d1,2,2.2,false,", - "1997-01-01T08:00:00.001Z,d2,11,11.1,false,", - "1997-01-01T08:00:00.002Z,d2,22,22.2,false,", - "1997-01-01T08:00:00.001Z,d3,null,111.1,true,", - "1997-01-01T08:00:00.004Z,d3,44,444.4,true,", - "1997-01-01T08:00:00.001Z,d4,1111,1111.1,true,", - "1997-01-01T08:00:00.005Z,d4,5555,5555.5,false,", + "1970-01-01T00:00:00.001Z,d1,1,1.1,false,", + "1970-01-01T00:00:00.002Z,d1,2,2.2,false,", + "1970-01-01T00:00:00.001Z,d2,11,11.1,false,", + "1970-01-01T00:00:00.002Z,d2,22,22.2,false,", + "1970-01-01T00:00:00.001Z,d3,null,111.1,true,", + "1970-01-01T00:00:00.004Z,d3,44,444.4,true,", + "1970-01-01T00:00:00.001Z,d4,1111,1111.1,true,", + "1970-01-01T00:00:00.005Z,d4,5555,5555.5,false,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3, s1, s2 FROM table1 order by device_id;", + "SELECT time, device_id, s3, s1, s2 FROM table1 order by device_id", expectedHeader, retArray, DATABASE_NAME); @@ -90,28 +88,28 @@ public class IoTDBAlignByDeviceWithTemplateIT { expectedHeader = new String[] {"time", "device_id", "s1", "s2", "s3", "s1"}; retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,1.1,false,1,1.1,", - "1997-01-01T08:00:00.002Z,d1,2.2,false,2,2.2,", - "1997-01-01T08:00:00.001Z,d2,11.1,false,11,11.1,", - "1997-01-01T08:00:00.002Z,d2,22.2,false,22,22.2,", - "1997-01-01T08:00:00.001Z,d3,111.1,true,null,111.1,", - "1997-01-01T08:00:00.004Z,d3,444.4,true,44,444.4,", - "1997-01-01T08:00:00.001Z,d4,1111.1,true,1111,1111.1,", - "1997-01-01T08:00:00.005Z,d4,5555.5,false,5555,5555.5,", + "1970-01-01T00:00:00.001Z,d1,1.1,false,1,1.1,", + "1970-01-01T00:00:00.002Z,d1,2.2,false,2,2.2,", + "1970-01-01T00:00:00.001Z,d2,11.1,false,11,11.1,", + "1970-01-01T00:00:00.002Z,d2,22.2,false,22,22.2,", + "1970-01-01T00:00:00.001Z,d3,111.1,true,null,111.1,", + "1970-01-01T00:00:00.004Z,d3,444.4,true,44,444.4,", + "1970-01-01T00:00:00.001Z,d4,1111.1,true,1111,1111.1,", + "1970-01-01T00:00:00.005Z,d4,5555.5,false,5555,5555.5,", }; tableResultSetEqualTest( - "SELECT *, s1 FROM table1 order by device_id;", expectedHeader, retArray, DATABASE_NAME); + "SELECT *, s1 FROM table1 order by device_id", expectedHeader, retArray, DATABASE_NAME); expectedHeader = new String[] {"time", "device_id", "s1", "s2", "s3"}; retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,1.1,false,1,", - "1997-01-01T08:00:00.002Z,d1,2.2,false,2,", - "1997-01-01T08:00:00.001Z,d2,11.1,false,11,", - "1997-01-01T08:00:00.002Z,d2,22.2,false,22,", + "1970-01-01T00:00:00.001Z,d1,1.1,false,1,", + "1970-01-01T00:00:00.002Z,d1,2.2,false,2,", + "1970-01-01T00:00:00.001Z,d2,11.1,false,11,", + "1970-01-01T00:00:00.002Z,d2,22.2,false,22,", }; tableResultSetEqualTest( - "SELECT * FROM table1 where device_id = 'd1' or device_id = 'd2' or device_id = 'd3' order by device_id;", + "SELECT * FROM table1 where device_id = 'd1' or device_id = 'd2' or device_id = 'd6' order by device_id", expectedHeader, retArray, DATABASE_NAME); @@ -120,10 +118,10 @@ public class IoTDBAlignByDeviceWithTemplateIT { expectedHeader = new String[] {"time", "device_id", "s1", "s2", "s3"}; retArray = new String[] { - "1997-01-01T08:00:00.002Z,d1,2.2,false,2,", "1997-01-01T08:00:00.001Z,d2,11.1,false,11,", + "1970-01-01T00:00:00.002Z,d1,2.2,false,2,", "1970-01-01T00:00:00.001Z,d2,11.1,false,11,", }; tableResultSetEqualTest( - "SELECT * FROM table1 order by device_id OFFSET 1 LIMIT 2;", + "SELECT * FROM table1 order by device_id OFFSET 1 LIMIT 2", expectedHeader, retArray, DATABASE_NAME); @@ -131,17 +129,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 3. order by time retArray = new String[] { - "1997-01-01T08:00:00.005Z,d4,5555.5,false,5555,", - "1997-01-01T08:00:00.004Z,d3,444.4,true,44,", - "1997-01-01T08:00:00.002Z,d1,2.2,false,2,", - "1997-01-01T08:00:00.002Z,d2,22.2,false,22,", - "1997-01-01T08:00:00.001Z,d1,1.1,false,1,", - "1997-01-01T08:00:00.001Z,d2,11.1,false,11,", - "1997-01-01T08:00:00.001Z,d3,111.1,true,null,", - "1997-01-01T08:00:00.001Z,d4,1111.1,true,1111,", + "1970-01-01T00:00:00.005Z,d4,5555.5,false,5555,", + "1970-01-01T00:00:00.004Z,d3,444.4,true,44,", + "1970-01-01T00:00:00.002Z,d1,2.2,false,2,", + "1970-01-01T00:00:00.002Z,d2,22.2,false,22,", + "1970-01-01T00:00:00.001Z,d1,1.1,false,1,", + "1970-01-01T00:00:00.001Z,d2,11.1,false,11,", + "1970-01-01T00:00:00.001Z,d3,111.1,true,null,", + "1970-01-01T00:00:00.001Z,d4,1111.1,true,1111,", }; tableResultSetEqualTest( - "SELECT * FROM table1 ORDER BY time DESC, device_id ASC;", + "SELECT * FROM table1 ORDER BY time DESC, device_id ASC", expectedHeader, retArray, DATABASE_NAME); @@ -149,13 +147,13 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 4. order by time + limit/offset retArray = new String[] { - "1997-01-01T08:00:00.005Z,d4,5555.5,false,5555,", - "1997-01-01T08:00:00.004Z,d3,444.4,true,44,", - "1997-01-01T08:00:00.002Z,d1,2.2,false,2,", - "1997-01-01T08:00:00.002Z,d2,22.2,false,22,", + "1970-01-01T00:00:00.005Z,d4,5555.5,false,5555,", + "1970-01-01T00:00:00.004Z,d3,444.4,true,44,", + "1970-01-01T00:00:00.002Z,d1,2.2,false,2,", + "1970-01-01T00:00:00.002Z,d2,22.2,false,22,", }; tableResultSetEqualTest( - "SELECT * FROM table1 ORDER BY time DESC, device_id LIMIT 4;", + "SELECT * FROM table1 ORDER BY time DESC, device_id LIMIT 4", expectedHeader, retArray, DATABASE_NAME); @@ -167,17 +165,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] expectedHeader = new String[] {"time", "device_id", "s3", "s1"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,1,1.1,", - "1997-01-01T08:00:00.002Z,d1,2,2.2,", - "1997-01-01T08:00:00.001Z,d2,11,11.1,", - "1997-01-01T08:00:00.002Z,d2,22,22.2,", - "1997-01-01T08:00:00.001Z,d3,null,111.1,", - "1997-01-01T08:00:00.004Z,d3,44,444.4,", - "1997-01-01T08:00:00.001Z,d4,1111,1111.1,", - "1997-01-01T08:00:00.005Z,d4,5555,5555.5,", + "1970-01-01T00:00:00.001Z,d1,1,1.1,", + "1970-01-01T00:00:00.002Z,d1,2,2.2,", + "1970-01-01T00:00:00.001Z,d2,11,11.1,", + "1970-01-01T00:00:00.002Z,d2,22,22.2,", + "1970-01-01T00:00:00.001Z,d3,null,111.1,", + "1970-01-01T00:00:00.004Z,d3,44,444.4,", + "1970-01-01T00:00:00.001Z,d4,1111,1111.1,", + "1970-01-01T00:00:00.005Z,d4,5555,5555.5,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3, s1 FROM table1 order by device_id;", + "SELECT time, device_id, s3, s1 FROM table1 order by device_id", expectedHeader, retArray, DATABASE_NAME); @@ -186,7 +184,7 @@ public class IoTDBAlignByDeviceWithTemplateIT { try (Statement statement = connection.createStatement()) { statement.execute("use " + DATABASE_NAME); try (ResultSet resultSet = - statement.executeQuery("SELECT s3,s1,s_null FROM table1 order by device_id;")) { + statement.executeQuery("SELECT s3,s1,s_null FROM table1 order by device_id")) { fail("should throw exception to indicate that s_null doesn't exist"); } catch (SQLException e) { assertEquals("701: Column 's_null' cannot be resolved", e.getMessage()); @@ -200,10 +198,10 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 2. order by device + limit/offset retArray = new String[] { - "1997-01-01T08:00:00.002Z,d1,2,2.2,", "1997-01-01T08:00:00.001Z,d2,11,11.1,", + "1970-01-01T00:00:00.002Z,d1,2,2.2,", "1970-01-01T00:00:00.001Z,d2,11,11.1,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3,s1 FROM table1 order by device_id OFFSET 1 LIMIT 2;", + "SELECT time, device_id, s3,s1 FROM table1 order by device_id OFFSET 1 LIMIT 2", expectedHeader, retArray, DATABASE_NAME); @@ -211,17 +209,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 3. order by time retArray = new String[] { - "1997-01-01T08:00:00.005Z,d4,5555,5555.5,", - "1997-01-01T08:00:00.004Z,d3,44,444.4,", - "1997-01-01T08:00:00.002Z,d1,2,2.2,", - "1997-01-01T08:00:00.002Z,d2,22,22.2,", - "1997-01-01T08:00:00.001Z,d1,1,1.1,", - "1997-01-01T08:00:00.001Z,d2,11,11.1,", - "1997-01-01T08:00:00.001Z,d3,null,111.1,", - "1997-01-01T08:00:00.001Z,d4,1111,1111.1,", + "1970-01-01T00:00:00.005Z,d4,5555,5555.5,", + "1970-01-01T00:00:00.004Z,d3,44,444.4,", + "1970-01-01T00:00:00.002Z,d1,2,2.2,", + "1970-01-01T00:00:00.002Z,d2,22,22.2,", + "1970-01-01T00:00:00.001Z,d1,1,1.1,", + "1970-01-01T00:00:00.001Z,d2,11,11.1,", + "1970-01-01T00:00:00.001Z,d3,null,111.1,", + "1970-01-01T00:00:00.001Z,d4,1111,1111.1,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3,s1 FROM table1 ORDER BY TIME DESC, device_id;", + "SELECT time, device_id, s3,s1 FROM table1 ORDER BY TIME DESC, device_id", expectedHeader, retArray, DATABASE_NAME); @@ -229,13 +227,13 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 4. order by time + limit/offset retArray = new String[] { - "1997-01-01T08:00:00.005Z,d4,5555,5555.5,", - "1997-01-01T08:00:00.004Z,d3,44,444.4,", - "1997-01-01T08:00:00.002Z,d1,2,2.2,", - "1997-01-01T08:00:00.002Z,d2,22,22.2,", + "1970-01-01T00:00:00.005Z,d4,5555,5555.5,", + "1970-01-01T00:00:00.004Z,d3,44,444.4,", + "1970-01-01T00:00:00.002Z,d1,2,2.2,", + "1970-01-01T00:00:00.002Z,d2,22,22.2,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3,s1 FROM table1 ORDER BY time DESC, device_id LIMIT 4;", + "SELECT time, device_id, s3,s1 FROM table1 ORDER BY time DESC, device_id LIMIT 4", expectedHeader, retArray, DATABASE_NAME); @@ -247,13 +245,13 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] expectedHeader = new String[] {"time", "device_id", "s1", "s2", "s3"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.004Z,d3,444.4,true,44,", - "1997-01-01T08:00:00.002Z,d1,2.2,false,2,", - "1997-01-01T08:00:00.002Z,d2,22.2,false,22,", - "1997-01-01T08:00:00.001Z,d1,1.1,false,1,", + "1970-01-01T00:00:00.004Z,d3,444.4,true,44,", + "1970-01-01T00:00:00.002Z,d1,2.2,false,2,", + "1970-01-01T00:00:00.002Z,d2,22.2,false,22,", + "1970-01-01T00:00:00.001Z,d1,1.1,false,1,", }; tableResultSetEqualTest( - "SELECT * FROM table1 WHERE time < 5 ORDER BY TIME DESC LIMIT 4;", + "SELECT * FROM table1 WHERE time < 5 ORDER BY TIME desc, device_id LIMIT 4", expectedHeader, retArray, DATABASE_NAME); @@ -261,8 +259,8 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 2. order by time + time filter + value filter retArray = new String[] { - "1997-01-01T08:00:00.004Z,d3,444.4,true,44,", - "1997-01-01T08:00:00.002Z,d2,22.2,false,22,", + "1970-01-01T00:00:00.004Z,d3,444.4,true,44,", + "1970-01-01T00:00:00.002Z,d2,22.2,false,22,", }; tableResultSetEqualTest( "SELECT * FROM table1 where time > 1 and time < 5 and s3>=11 and s3<=1111 and s1 != 11.1 " @@ -276,7 +274,7 @@ public class IoTDBAlignByDeviceWithTemplateIT { try (Statement statement = connection.createStatement()) { statement.execute("use " + DATABASE_NAME); try (ResultSet resultSet = - statement.executeQuery("SELECT * FROM table1 WHERE s_null > 1 order by device_id;")) { + statement.executeQuery("SELECT * FROM table1 WHERE s_null > 1 order by device_id")) { fail("should throw exception to indicate that s_null doesn't exist"); } catch (SQLException e) { assertEquals("701: Column 's_null' cannot be resolved", e.getMessage()); @@ -295,10 +293,10 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d4,1111.1,true,1111,", - "1997-01-01T08:00:00.001Z,d3,111.1,true,null,", - "1997-01-01T08:00:00.004Z,d3,444.4,true,44,", - "1997-01-01T08:00:00.001Z,d2,11.1,false,11,", + "1970-01-01T00:00:00.001Z,d4,1111.1,true,1111,", + "1970-01-01T00:00:00.001Z,d3,111.1,true,null,", + "1970-01-01T00:00:00.004Z,d3,444.4,true,44,", + "1970-01-01T00:00:00.001Z,d2,11.1,false,11,", }; tableResultSetEqualTest( "SELECT * FROM table1 WHERE time < 5 ORDER BY device_id DESC LIMIT 4", @@ -309,12 +307,12 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 2. order by device + time filter + value filter retArray = new String[] { - "1997-01-01T08:00:00.004Z,d3,444.4,true,44,", - "1997-01-01T08:00:00.001Z,d2,22.2,false,22,", + "1970-01-01T00:00:00.004Z,d3,444.4,true,44,", + "1970-01-01T00:00:00.002Z,d2,22.2,false,22,", }; tableResultSetEqualTest( "SELECT * FROM table1 where time > 1 and time < 5 and s3>=11 and s3<=1111 and s1 != 11.1 " - + "ORDER BY device_id DESC;", + + "ORDER BY device_id DESC", expectedHeader, retArray, DATABASE_NAME); @@ -326,13 +324,13 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] expectedHeader = new String[] {"time", "device_id", "s3", "s2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.004Z,d3,44,true,", - "1997-01-01T08:00:00.002Z,d1,2,false,", - "1997-01-01T08:00:00.002Z,d2,22,false,", - "1997-01-01T08:00:00.001Z,d1,1,false,", + "1970-01-01T00:00:00.004Z,d3,44,true,", + "1970-01-01T00:00:00.002Z,d1,2,false,", + "1970-01-01T00:00:00.002Z,d2,22,false,", + "1970-01-01T00:00:00.001Z,d1,1,false,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3, s2 FROM table1 WHERE time < 5 ORDER BY time DESC, device_id LIMIT 4;", + "SELECT time, device_id, s3, s2 FROM table1 WHERE time < 5 ORDER BY time DESC, device_id LIMIT 4", expectedHeader, retArray, DATABASE_NAME); @@ -340,11 +338,11 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 2. order by time + time filter + value filter retArray = new String[] { - "1997-01-01T08:00:00.004Z,d3,44,true,", "1997-01-01T08:00:00.002Z,d2,22,false,", + "1970-01-01T00:00:00.004Z,d3,44,true,", "1970-01-01T00:00:00.002Z,d2,22,false,", }; tableResultSetEqualTest( "SELECT time, device_id, s3,s2 FROM table1 where time > 1 and time < 5 and s3>=11 and s3<=1111 and s1 != 11.1 " - + "ORDER BY time DESC, device_id;", + + "ORDER BY time DESC, device_id", expectedHeader, retArray, DATABASE_NAME); @@ -356,13 +354,13 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] expectedHeader = new String[] {"time", "device_id", "s3", "s2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,d4,1111,true,", - "1997-01-01T08:00:00.001Z,d3,null,true,", - "1997-01-01T08:00:00.004Z,d3,44,true,", - "1997-01-01T08:00:00.001Z,d2,11,false,", + "1970-01-01T00:00:00.001Z,d4,1111,true,", + "1970-01-01T00:00:00.001Z,d3,null,true,", + "1970-01-01T00:00:00.004Z,d3,44,true,", + "1970-01-01T00:00:00.001Z,d2,11,false,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3,s2 FROM table1 WHERE time < 5 ORDER BY DEVICE DESC, time LIMIT 4", + "SELECT time, device_id, s3,s2 FROM table1 WHERE time < 5 ORDER BY device_id DESC, time LIMIT 4", expectedHeader, retArray, DATABASE_NAME); @@ -370,11 +368,11 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 2. order by device + time filter + value filter retArray = new String[] { - "1997-01-01T08:00:00.004Z,d3,44,true,", "1997-01-01T08:00:00.002Z,d2,22,false,", + "1970-01-01T00:00:00.004Z,d3,44,true,", "1970-01-01T00:00:00.002Z,d2,22,false,", }; tableResultSetEqualTest( "SELECT time, device_id, s3,s2 FROM table1 where time > 1 and time < 5 and s3>=11 and s3<=1111 and s1 != 11.1 " - + "ORDER BY DEVICE DESC, time asc", + + "ORDER BY device_id DESC, time asc", expectedHeader, retArray, DATABASE_NAME); @@ -386,17 +384,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] retArray = new String[] { - "1.1,false,1,false,1997-01-01T08:00:00.001Z,d1,", - "2.2,false,2,false,1997-01-01T08:00:00.002Z,d1,", - "11.1,false,11,false,1997-01-01T08:00:00.001Z,d2,", - "22.2,false,22,false,1997-01-01T08:00:00.002Z,d2,", - "111.1,true,null,true,1997-01-01T08:00:00.001Z,d3,", - "444.4,true,44,true,1997-01-01T08:00:00.004Z,d3,", - "1111.1,true,1111,true,1997-01-01T08:00:00.001Z,d4,", - "5555.5,false,5555,false,1997-01-01T08:00:00.005Z,d4,", + "1.1,false,1,false,1970-01-01T00:00:00.001Z,d1,", + "2.2,false,2,false,1970-01-01T00:00:00.002Z,d1,", + "11.1,false,11,false,1970-01-01T00:00:00.001Z,d2,", + "22.2,false,22,false,1970-01-01T00:00:00.002Z,d2,", + "111.1,true,null,true,1970-01-01T00:00:00.001Z,d3,", + "444.4,true,44,true,1970-01-01T00:00:00.004Z,d3,", + "1111.1,true,1111,true,1970-01-01T00:00:00.001Z,d4,", + "5555.5,false,5555,false,1970-01-01T00:00:00.005Z,d4,", }; tableResultSetEqualTest( - "SELECT s1 as aa, s2 as bb, s3, s2, time, device_id FROM table1;", + "SELECT s1 as aa, s2 as bb, s3, s2, time, device_id FROM table1 order by device_id", expectedHeader, retArray, DATABASE_NAME); @@ -405,17 +403,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,1.1,1.1,", - "1997-01-01T08:00:00.002Z,d1,2.2,2.2,", - "1997-01-01T08:00:00.001Z,d2,11.1,11.1,", - "1997-01-01T08:00:00.002Z,d2,22.2,22.2,", - "1997-01-01T08:00:00.001Z,d3,111.1,111.1,", - "1997-01-01T08:00:00.004Z,d3,444.4,444.4,", - "1997-01-01T08:00:00.001Z,d4,1111.1,1111.1,", - "1997-01-01T08:00:00.005Z,d4,5555.5,5555.5,", + "1970-01-01T00:00:00.001Z,d1,1.1,1.1,", + "1970-01-01T00:00:00.002Z,d1,2.2,2.2,", + "1970-01-01T00:00:00.001Z,d2,11.1,11.1,", + "1970-01-01T00:00:00.002Z,d2,22.2,22.2,", + "1970-01-01T00:00:00.001Z,d3,111.1,111.1,", + "1970-01-01T00:00:00.004Z,d3,444.4,444.4,", + "1970-01-01T00:00:00.001Z,d4,1111.1,1111.1,", + "1970-01-01T00:00:00.005Z,d4,5555.5,5555.5,", }; tableResultSetEqualTest( - "SELECT time, device_id, s1 as a, s1 as b FROM table1", + "SELECT time, device_id, s1 as a, s1 as b FROM table1 order by device_id", expectedHeader, retArray, DATABASE_NAME); @@ -427,17 +425,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { String[] expectedHeader = new String[] {"time", "device_id", "s3", "s1", "s2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.005Z,d4,5555,5555.5,false,", - "1997-01-01T08:00:00.002Z,d2,22,22.2,false,", - "1997-01-01T08:00:00.001Z,d2,11,11.1,false,", - "1997-01-01T08:00:00.002Z,d1,2,2.2,false,", - "1997-01-01T08:00:00.001Z,d1,1,1.1,false,", - "1997-01-01T08:00:00.001Z,d4,1111,1111.1,true,", - "1997-01-01T08:00:00.004Z,d3,44,444.4,true,", - "1997-01-01T08:00:00.001Z,d3,null,111.1,true,", + "1970-01-01T00:00:00.005Z,d4,5555,5555.5,false,", + "1970-01-01T00:00:00.002Z,d2,22,22.2,false,", + "1970-01-01T00:00:00.001Z,d2,11,11.1,false,", + "1970-01-01T00:00:00.002Z,d1,2,2.2,false,", + "1970-01-01T00:00:00.001Z,d1,1,1.1,false,", + "1970-01-01T00:00:00.001Z,d4,1111,1111.1,true,", + "1970-01-01T00:00:00.004Z,d3,44,444.4,true,", + "1970-01-01T00:00:00.001Z,d3,null,111.1,true,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3, s1, s2 FROM table1 order by s2 asc, s1 desc, device_id;", + "SELECT time, device_id, s3, s1, s2 FROM table1 order by s2 asc, s1 desc, device_id", expectedHeader, retArray, DATABASE_NAME); @@ -446,14 +444,14 @@ public class IoTDBAlignByDeviceWithTemplateIT { expectedHeader = new String[] {"time", "device_id", "s3"}; retArray = new String[] { - "1997-01-01T08:00:00.005Z,d4,5555,", - "1997-01-01T08:00:00.002Z,d2,22,", - "1997-01-01T08:00:00.001Z,d2,11,", - "1997-01-01T08:00:00.002Z,d1,2,", - "1997-01-01T08:00:00.001Z,d1,1,", - "1997-01-01T08:00:00.001Z,d4,1111,", - "1997-01-01T08:00:00.004Z,d3,44,", - "1997-01-01T08:00:00.001Z,d3,null,", + "1970-01-01T00:00:00.005Z,d4,5555,", + "1970-01-01T00:00:00.002Z,d2,22,", + "1970-01-01T00:00:00.001Z,d2,11,", + "1970-01-01T00:00:00.002Z,d1,2,", + "1970-01-01T00:00:00.001Z,d1,1,", + "1970-01-01T00:00:00.001Z,d4,1111,", + "1970-01-01T00:00:00.004Z,d3,44,", + "1970-01-01T00:00:00.001Z,d3,null,", }; tableResultSetEqualTest( "SELECT time, device_id, s3 FROM table1 order by s2 asc, s1 desc", @@ -464,17 +462,17 @@ public class IoTDBAlignByDeviceWithTemplateIT { // 3. order by expression retArray = new String[] { - "1997-01-01T08:00:00.005Z,d4,5555,", - "1997-01-01T08:00:00.001Z,d4,1111,", - "1997-01-01T08:00:00.004Z,d3,44,", - "1997-01-01T08:00:00.002Z,d2,22,", - "1997-01-01T08:00:00.001Z,d2,11,", - "1997-01-01T08:00:00.002Z,d1,2,", - "1997-01-01T08:00:00.001Z,d1,1,", - "1997-01-01T08:00:00.001Z,d3,null,", + "1970-01-01T00:00:00.005Z,d4,5555,", + "1970-01-01T00:00:00.001Z,d4,1111,", + "1970-01-01T00:00:00.004Z,d3,44,", + "1970-01-01T00:00:00.002Z,d2,22,", + "1970-01-01T00:00:00.001Z,d2,11,", + "1970-01-01T00:00:00.002Z,d1,2,", + "1970-01-01T00:00:00.001Z,d1,1,", + "1970-01-01T00:00:00.001Z,d3,null,", }; tableResultSetEqualTest( - "SELECT time, device_id, s3 FROM root.sg1.** order by s1+s3 desc", + "SELECT time, device_id, s3 FROM table1 order by s1+s3 desc", expectedHeader, retArray, DATABASE_NAME); diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceIT.java index f94f7a5eb7f..2e80792f5ee 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceIT.java @@ -55,7 +55,7 @@ public class IoTDBOrderByLimitOffsetAlignByDeviceIT { public void orderByCanNotPushLimitTest() { // 1. value filter, can not push down LIMIT String[] expectedHeader = new String[] {"time", "device_id", "s1"}; - String[] retArray = new String[] {"1997-01-01T08:00:00.003Z,d1,111,"}; + String[] retArray = new String[] {"1970-01-01T00:00:00.003Z,d1,111,"}; tableResultSetEqualTest( "SELECT * FROM table1 WHERE s1>40 ORDER BY Time LIMIT 1", expectedHeader, @@ -63,20 +63,20 @@ public class IoTDBOrderByLimitOffsetAlignByDeviceIT { DATABASE_NAME); // 2. order by expression, can not push down LIMIT - retArray = new String[] {"1997-01-01T08:00:00.003Z,d3,333,"}; + retArray = new String[] {"1970-01-01T00:00:00.003Z,d3,333,"}; tableResultSetEqualTest( "SELECT * FROM table1 ORDER BY s1 DESC LIMIT 1", expectedHeader, retArray, DATABASE_NAME); // 3. time filter, can push down LIMIT - retArray = new String[] {"1997-01-01T08:00:00.002Z,d3,33,", "1997-01-01T08:00:00.002Z,d2,22,"}; + retArray = new String[] {"1970-01-01T00:00:00.002Z,d3,33,", "1970-01-01T00:00:00.002Z,d2,22,"}; tableResultSetEqualTest( - "SELECT * FROM table1 WHERE time>1 and time<3 ORDER BY device_id DESC LIMIT 2;", + "SELECT * FROM table1 WHERE time>1 and time<3 ORDER BY device_id DESC LIMIT 2", expectedHeader, retArray, DATABASE_NAME); // 4. both exist OFFSET and LIMIT, can push down LIMIT as OFFSET+LIMIT - retArray = new String[] {"1997-01-01T08:00:00.003Z,d2,222,"}; + retArray = new String[] {"1970-01-01T00:00:00.003Z,d2,222,"}; tableResultSetEqualTest( "SELECT * FROM table1 ORDER BY Time DESC OFFSET 1 LIMIT 1", expectedHeader, @@ -92,7 +92,7 @@ public class IoTDBOrderByLimitOffsetAlignByDeviceIT { // String[] retArray = new String[] {"3,root.db.d2,222.0,", "3,root.db.d3,333.0,"}; // resultSetEqualTest( // "select sum(s1) from root.db.** group by ((1,5],1ms) having(sum(s1)>111) order by time - // limit 2 align by device;", + // limit 2 align by device", // expectedHeader, // retArray); // } @@ -109,7 +109,7 @@ public class IoTDBOrderByLimitOffsetAlignByDeviceIT { // "2,root.fill.d1,22,11.0,", // }; // resultSetEqualTest( - // "select * from root.fill.** order by time fill(linear) limit 4 align by device;", + // "select * from root.fill.** order by time fill(linear) limit 4 align by device", // expectedHeader, // retArray); // } @@ -123,15 +123,15 @@ public class IoTDBOrderByLimitOffsetAlignByDeviceIT { "CREATE DATABASE " + DATABASE_NAME, "USE " + DATABASE_NAME, "create table table1(device_id STRING ID, s1 INT32 MEASUREMENT)", - "INSERT INTO table1(Time, device_id, s1) VALUES(1, 'd1', 1), (2, 'd1', 11), (3, 'd1', 111);", - "INSERT INTO table1(Time, device_id, s1) VALUES(1, 'd2', 2), (2, 'd2', 22), (3, 'd2', 222);", - "INSERT INTO table1(Time, device_id, s1) VALUES(1, 'd3', 3), (2, 'd3', 33), (3, 'd3', 333);", + "INSERT INTO table1(Time, device_id, s1) VALUES(1, 'd1', 1), (2, 'd1', 11), (3, 'd1', 111)", + "INSERT INTO table1(Time, device_id, s1) VALUES(1, 'd2', 2), (2, 'd2', 22), (3, 'd2', 222)", + "INSERT INTO table1(Time, device_id, s1) VALUES(1, 'd3', 3), (2, 'd3', 33), (3, 'd3', 333)", "CREATE DATABASE " + DATABASE_FILL_NAME, "USE " + DATABASE_FILL_NAME, "create table table1(device_id STRING ID, s1 INT32 MEASUREMENT, s2 FLOAT MEASUREMENT)", - "INSERT INTO table1(Time,device_id,s1,s2) VALUES(1, 'd1', 1, null), (2, 'd1', null, 11), (3, 'd1', 111, 111.1);", - "INSERT INTO table1(Time,device_id,s1,s2) VALUES(1, 'd2', 2, null), (2, 'd2', 22, 22.2), (3, 'd2', 222, null);", - "INSERT INTO table1(Time,device_id,s1,s2) VALUES(1, 'd3', 3, null), (2, 'd3', 33, null), (3, 'd3', 333, 333.3);", + "INSERT INTO table1(Time,device_id,s1,s2) VALUES(1, 'd1', 1, null), (2, 'd1', null, 11), (3, 'd1', 111, 111.1)", + "INSERT INTO table1(Time,device_id,s1,s2) VALUES(1, 'd2', 2, null), (2, 'd2', 22, 22.2), (3, 'd2', 222, null)", + "INSERT INTO table1(Time,device_id,s1,s2) VALUES(1, 'd3', 3, null), (2, 'd3', 33, null), (3, 'd3', 333, 333.3)", }; protected static void insertData3() { diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBCastFunctionIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBCastFunctionIT.java index dbce7468d0a..ba40f782452 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBCastFunctionIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBCastFunctionIT.java @@ -50,49 +50,49 @@ public class IoTDBCastFunctionIT { // normal cases "CREATE DATABASE " + DATABASE_NAME, "USE " + DATABASE_NAME, - "create table normal(device_id STRING ID, s1 INT32 MEASUREMENT, s2 INT64 MEASUREMENT, s3 FLOAT MEASUREMENT, s4 DOUBLE MEASUREMENT, s5 BOOLEAN MEASUREMENT, s6 STRING MEASUREMENT);", + "create table normal(device_id STRING ID, s1 INT32 MEASUREMENT, s2 INT64 MEASUREMENT, s3 FLOAT MEASUREMENT, s4 DOUBLE MEASUREMENT, s5 BOOLEAN MEASUREMENT, s6 STRING MEASUREMENT)", // data for int series - "INSERT INTO normal(Time, device_id ,s1) values(0, 'd1', 0)", - "INSERT INTO normal(Time, device_id ,s1) values(1, 'd1', 1)", - "INSERT INTO normal(Time, device_id ,s1) values(2, 'd1', 2)", - "INSERT INTO normal(Time, device_id ,s1) values(3, 'd1', 3)", + "INSERT INTO normal(time, device_id ,s1) values(0, 'd1', 0)", + "INSERT INTO normal(time, device_id ,s1) values(1, 'd1', 1)", + "INSERT INTO normal(time, device_id ,s1) values(2, 'd1', 2)", + "INSERT INTO normal(time, device_id ,s1) values(3, 'd1', 3)", // data for long series - "INSERT INTO normal(Time, device_id ,s2) values(0, 'd1', 0)", - "INSERT INTO normal(Time, device_id ,s2) values(1, 'd1', 1)", - "INSERT INTO normal(Time, device_id ,s2) values(2, 'd1', 2)", - "INSERT INTO normal(Time, device_id ,s2) values(3, 'd1', 3)", + "INSERT INTO normal(time, device_id ,s2) values(0, 'd1', 0)", + "INSERT INTO normal(time, device_id ,s2) values(1, 'd1', 1)", + "INSERT INTO normal(time, device_id ,s2) values(2, 'd1', 2)", + "INSERT INTO normal(time, device_id ,s2) values(3, 'd1', 3)", // data for float series - "INSERT INTO normal(Time, device_id ,s3) values(0, 'd1', 0)", - "INSERT INTO normal(Time, device_id ,s3) values(1, 'd1', 1)", - "INSERT INTO normal(Time, device_id ,s3) values(2, 'd1', 2.7)", - "INSERT INTO normal(Time, device_id ,s3) values(3, 'd1', 3.33)", + "INSERT INTO normal(time, device_id ,s3) values(0, 'd1', 0)", + "INSERT INTO normal(time, device_id ,s3) values(1, 'd1', 1)", + "INSERT INTO normal(time, device_id ,s3) values(2, 'd1', 2.7)", + "INSERT INTO normal(time, device_id ,s3) values(3, 'd1', 3.33)", // data for double series - "INSERT INTO normal(Time, device_id ,s3) values(0, 'd1', 0)", - "INSERT INTO normal(Time, device_id ,s3) values(1, 'd1', 1.0)", - "INSERT INTO normal(Time, device_id ,s3) values(2, 'd1', 2.7)", - "INSERT INTO normal(Time, device_id ,s3) values(3, 'd1', 3.33)", + "INSERT INTO normal(time, device_id ,s4) values(0, 'd1', 0)", + "INSERT INTO normal(time, device_id ,s4) values(1, 'd1', 1.0)", + "INSERT INTO normal(time, device_id ,s4) values(2, 'd1', 2.7)", + "INSERT INTO normal(time, device_id ,s4) values(3, 'd1', 3.33)", // data for boolean series - "INSERT INTO normal(Time, device_id ,s3) values(0, 'd1', false)", - "INSERT INTO normal(Time, device_id ,s3) values(1, 'd1', false)", - "INSERT INTO normal(Time, device_id ,s3) values(2, 'd1', true)", - "INSERT INTO normal(Time, device_id ,s3) values(3, 'd1', true)", + "INSERT INTO normal(time, device_id ,s5) values(0, 'd1', false)", + "INSERT INTO normal(time, device_id ,s5) values(1, 'd1', false)", + "INSERT INTO normal(time, device_id ,s5) values(2, 'd1', true)", + "INSERT INTO normal(time, device_id ,s5) values(3, 'd1', true)", // data for text series - "INSERT INTO normal(Time, device_id ,s3) values(0, 'd1', '10000')", - "INSERT INTO normal(Time, device_id ,s3) values(1, 'd1', 3)", - "INSERT INTO normal(Time, device_id ,s3) values(2, 'd1', 'TRue')", - "INSERT INTO normal(Time, device_id ,s3) values(3, 'd1', 'faLse')", + "INSERT INTO normal(time, device_id ,s6) values(0, 'd1', '10000')", + "INSERT INTO normal(time, device_id ,s6) values(1, 'd1', 3)", + "INSERT INTO normal(time, device_id ,s6) values(2, 'd1', 'TRue')", + "INSERT INTO normal(time, device_id ,s6) values(3, 'd1', 'faLse')", "flush", // special cases - "create table special(device_id STRING ID, s1 INT32 MEASUREMENT, s2 INT64 MEASUREMENT, s3 FLOAT MEASUREMENT, s4 DOUBLE MEASUREMENT, s5 BOOLEAN MEASUREMENT, s6 STRING MEASUREMENT);", - "INSERT INTO normal(Time, device_id ,s2) values(1, 'd1', 2147483648)", - "INSERT INTO normal(Time, device_id ,s3) values(1, 'd1', 2147483648.0)", - "INSERT INTO normal(Time, device_id ,s3) values(2, 'd1', 2e38)", - "INSERT INTO normal(Time, device_id ,s4) values(1, 'd1', 4e50)", - "INSERT INTO normal(Time, device_id ,s6) values(1, 'd1', 'test')", - "INSERT INTO normal(Time, device_id ,s6) values(2, 'd1', '1.1')", - "INSERT INTO normal(Time, device_id ,s6) values(3, 'd1', '4e60')", - "INSERT INTO normal(Time, device_id ,s6) values(4, 'd1', '4e60000')", + "create table special(device_id STRING ID, s1 INT32 MEASUREMENT, s2 INT64 MEASUREMENT, s3 FLOAT MEASUREMENT, s4 DOUBLE MEASUREMENT, s5 BOOLEAN MEASUREMENT, s6 STRING MEASUREMENT)", + "INSERT INTO special(Time, device_id ,s2) values(1, 'd1', 2147483648)", + "INSERT INTO special(Time, device_id ,s3) values(1, 'd1', 2147483648.0)", + "INSERT INTO special(Time, device_id ,s3) values(2, 'd1', 2e38)", + "INSERT INTO special(Time, device_id ,s4) values(1, 'd1', 4e50)", + "INSERT INTO special(Time, device_id ,s6) values(1, 'd1', 'test')", + "INSERT INTO special(Time, device_id ,s6) values(2, 'd1', '1.1')", + "INSERT INTO special(Time, device_id ,s6) values(3, 'd1', '4e60')", + "INSERT INTO special(Time, device_id ,s6) values(4, 'd1', '4e60000')", }; @BeforeClass @@ -125,10 +125,10 @@ public class IoTDBCastFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "cast_s1"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,2,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s1 AS INT32) as cast_s1 from normal where device_id='d1'", @@ -139,10 +139,10 @@ public class IoTDBCastFunctionIT { // cast to long String[] longRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,2,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s1 AS INT64) as cast_s1 from normal where device_id='d1'", @@ -153,10 +153,10 @@ public class IoTDBCastFunctionIT { // cast to float String[] floatRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.0,", - "1997-01-01T08:00:00.003Z,3.0,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.0,", + "1970-01-01T00:00:00.003Z,3.0,", }; tableResultSetEqualTest( "select Time, CAST(s1 AS FLOAT) as cast_s1 from normal where device_id='d1'", @@ -167,10 +167,10 @@ public class IoTDBCastFunctionIT { // cast to double String[] doubleRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.0,", - "1997-01-01T08:00:00.003Z,3.0,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.0,", + "1970-01-01T00:00:00.003Z,3.0,", }; tableResultSetEqualTest( "select Time, CAST(s1 AS DOUBLE) as cast_s1 from normal where device_id='d1'", @@ -181,10 +181,10 @@ public class IoTDBCastFunctionIT { // cast to boolean String[] booleanRetArray = new String[] { - "1997-01-01T08:00:00.000Z,false,", - "1997-01-01T08:00:00.001Z,true,", - "1997-01-01T08:00:00.002Z,true,", - "1997-01-01T08:00:00.003Z,true,", + "1970-01-01T00:00:00.000Z,false,", + "1970-01-01T00:00:00.001Z,true,", + "1970-01-01T00:00:00.002Z,true,", + "1970-01-01T00:00:00.003Z,true,", }; tableResultSetEqualTest( "select Time, CAST(s1 AS BOOLEAN) as cast_s1 from normal where device_id='d1'", @@ -195,10 +195,10 @@ public class IoTDBCastFunctionIT { // cast to string String[] stringRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,2,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s1 AS STRING) as cast_s1 from normal where device_id='d1'", @@ -213,10 +213,10 @@ public class IoTDBCastFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "cast_s2"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,2,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( @@ -228,10 +228,10 @@ public class IoTDBCastFunctionIT { // cast to long String[] longRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,2,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s2 AS INT64) as cast_s2 from normal where device_id='d1'", @@ -242,10 +242,10 @@ public class IoTDBCastFunctionIT { // cast to float String[] floatRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.0,", - "1997-01-01T08:00:00.003Z,3.0,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.0,", + "1970-01-01T00:00:00.003Z,3.0,", }; tableResultSetEqualTest( "select Time, CAST(s2 AS FLOAT) as cast_s2 from normal where device_id='d1'", @@ -256,10 +256,10 @@ public class IoTDBCastFunctionIT { // cast to double String[] doubleRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.0,", - "1997-01-01T08:00:00.003Z,3.0,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.0,", + "1970-01-01T00:00:00.003Z,3.0,", }; tableResultSetEqualTest( "select Time, CAST(s2 AS DOUBLE) as cast_s2 from normal where device_id='d1'", @@ -270,10 +270,10 @@ public class IoTDBCastFunctionIT { // cast to boolean String[] booleanRetArray = new String[] { - "1997-01-01T08:00:00.000Z,false,", - "1997-01-01T08:00:00.001Z,true,", - "1997-01-01T08:00:00.002Z,true,", - "1997-01-01T08:00:00.003Z,true,", + "1970-01-01T00:00:00.000Z,false,", + "1970-01-01T00:00:00.001Z,true,", + "1970-01-01T00:00:00.002Z,true,", + "1970-01-01T00:00:00.003Z,true,", }; tableResultSetEqualTest( "select Time, CAST(s2 AS BOOLEAN) as cast_s2 from normal where device_id='d1'", @@ -284,10 +284,10 @@ public class IoTDBCastFunctionIT { // cast to text String[] stringRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,2,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s2 AS STRING) as cast_s2 from normal where device_id='d1'", @@ -302,10 +302,10 @@ public class IoTDBCastFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "cast_s3"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,3,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s3 AS INT32) as cast_s3 from normal where device_id='d1'", @@ -316,10 +316,10 @@ public class IoTDBCastFunctionIT { // cast to long String[] longRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,3,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s3 AS INT64) as cast_s3 from normal where device_id='d1'", @@ -330,10 +330,10 @@ public class IoTDBCastFunctionIT { // cast to float String[] floatRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.7,", - "1997-01-01T08:00:00.003Z,3.33,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.7,", + "1970-01-01T00:00:00.003Z,3.33,", }; tableResultSetEqualTest( "select Time, CAST(s3 AS FLOAT) as cast_s3 from normal where device_id='d1'", @@ -344,10 +344,10 @@ public class IoTDBCastFunctionIT { // cast to double String[] doubleRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.700000047683716,", - "1997-01-01T08:00:00.003Z,3.3299999237060547,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.700000047683716,", + "1970-01-01T00:00:00.003Z,3.3299999237060547,", }; tableResultSetEqualTest( "select Time, CAST(s3 AS DOUBLE) as cast_s3 from normal where device_id='d1'", @@ -358,10 +358,10 @@ public class IoTDBCastFunctionIT { // cast to boolean String[] booleanRetArray = new String[] { - "1997-01-01T08:00:00.000Z,false,", - "1997-01-01T08:00:00.001Z,true,", - "1997-01-01T08:00:00.002Z,true,", - "1997-01-01T08:00:00.003Z,true,", + "1970-01-01T00:00:00.000Z,false,", + "1970-01-01T00:00:00.001Z,true,", + "1970-01-01T00:00:00.002Z,true,", + "1970-01-01T00:00:00.003Z,true,", }; tableResultSetEqualTest( "select Time, CAST(s3 AS BOOLEAN) as cast_s3 from normal where device_id='d1'", @@ -372,10 +372,10 @@ public class IoTDBCastFunctionIT { // cast to text String[] stringRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.7,", - "1997-01-01T08:00:00.003Z,3.33,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.7,", + "1970-01-01T00:00:00.003Z,3.33,", }; tableResultSetEqualTest( "select Time, CAST(s3 AS STRING) as cast_s3 from normal where device_id='d1'", @@ -390,10 +390,10 @@ public class IoTDBCastFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "cast_s4"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,3,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s4 AS INT32) as cast_s4 from normal where device_id='d1'", @@ -404,10 +404,10 @@ public class IoTDBCastFunctionIT { // cast to long String[] longRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,1,", - "1997-01-01T08:00:00.002Z,2,", - "1997-01-01T08:00:00.003Z,3,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,1,", + "1970-01-01T00:00:00.002Z,3,", + "1970-01-01T00:00:00.003Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s4 AS INT64) as cast_s4 from normal where device_id='d1'", @@ -418,10 +418,10 @@ public class IoTDBCastFunctionIT { // cast to float String[] floatRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0。0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.7,", - "1997-01-01T08:00:00.003Z,3.33,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.7,", + "1970-01-01T00:00:00.003Z,3.33,", }; tableResultSetEqualTest( "select Time, CAST(s4 AS FLOAT) as cast_s4 from normal where device_id='d1'", @@ -432,10 +432,10 @@ public class IoTDBCastFunctionIT { // cast to double String[] doubleRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0。0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.7,", - "1997-01-01T08:00:00.003Z,3.33,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.7,", + "1970-01-01T00:00:00.003Z,3.33,", }; tableResultSetEqualTest( "select Time, CAST(s4 AS DOUBLE) as cast_s4 from normal where device_id='d1'", @@ -446,10 +446,10 @@ public class IoTDBCastFunctionIT { // cast to boolean String[] booleanRetArray = new String[] { - "1997-01-01T08:00:00.000Z,false,", - "1997-01-01T08:00:00.001Z,true,", - "1997-01-01T08:00:00.002Z,true,", - "1997-01-01T08:00:00.003Z,true,", + "1970-01-01T00:00:00.000Z,false,", + "1970-01-01T00:00:00.001Z,true,", + "1970-01-01T00:00:00.002Z,true,", + "1970-01-01T00:00:00.003Z,true,", }; tableResultSetEqualTest( "select Time, CAST(s4 AS BOOLEAN) as cast_s4 from normal where device_id='d1'", @@ -460,10 +460,10 @@ public class IoTDBCastFunctionIT { // cast to string String[] stringRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0。0,", - "1997-01-01T08:00:00.001Z,1.0,", - "1997-01-01T08:00:00.002Z,2.7,", - "1997-01-01T08:00:00.003Z,3.33,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,1.0,", + "1970-01-01T00:00:00.002Z,2.7,", + "1970-01-01T00:00:00.003Z,3.33,", }; tableResultSetEqualTest( "select Time, CAST(s4 AS STRING) as cast_s4 from normal where device_id='d1'", @@ -478,10 +478,10 @@ public class IoTDBCastFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "cast_s5"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,0,", - "1997-01-01T08:00:00.002Z,1,", - "1997-01-01T08:00:00.003Z,1,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,0,", + "1970-01-01T00:00:00.002Z,1,", + "1970-01-01T00:00:00.003Z,1,", }; tableResultSetEqualTest( "select Time, CAST(s5 AS INT32) as cast_s5 from normal where device_id='d1'", @@ -492,10 +492,10 @@ public class IoTDBCastFunctionIT { // cast to long String[] longRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0,", - "1997-01-01T08:00:00.001Z,0,", - "1997-01-01T08:00:00.002Z,1,", - "1997-01-01T08:00:00.003Z,1,", + "1970-01-01T00:00:00.000Z,0,", + "1970-01-01T00:00:00.001Z,0,", + "1970-01-01T00:00:00.002Z,1,", + "1970-01-01T00:00:00.003Z,1,", }; tableResultSetEqualTest( "select Time, CAST(s5 AS INT64) as cast_s5 from normal where device_id='d1'", @@ -506,10 +506,10 @@ public class IoTDBCastFunctionIT { // cast to float String[] floatRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,0.0,", - "1997-01-01T08:00:00.002Z,1.0,", - "1997-01-01T08:00:00.003Z,1.0,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,0.0,", + "1970-01-01T00:00:00.002Z,1.0,", + "1970-01-01T00:00:00.003Z,1.0,", }; tableResultSetEqualTest( "select Time, CAST(s5 AS FLOAT) as cast_s5 from normal where device_id='d1'", @@ -520,10 +520,10 @@ public class IoTDBCastFunctionIT { // cast to double String[] doubleRetArray = new String[] { - "1997-01-01T08:00:00.000Z,0.0,", - "1997-01-01T08:00:00.001Z,0.0,", - "1997-01-01T08:00:00.002Z,1.0,", - "1997-01-01T08:00:00.003Z,1.0,", + "1970-01-01T00:00:00.000Z,0.0,", + "1970-01-01T00:00:00.001Z,0.0,", + "1970-01-01T00:00:00.002Z,1.0,", + "1970-01-01T00:00:00.003Z,1.0,", }; tableResultSetEqualTest( "select Time, CAST(s5 AS DOUBLE) as cast_s5 from normal where device_id='d1'", @@ -534,10 +534,10 @@ public class IoTDBCastFunctionIT { // cast to boolean String[] booleanRetArray = new String[] { - "1997-01-01T08:00:00.000Z,false,", - "1997-01-01T08:00:00.001Z,false,", - "1997-01-01T08:00:00.002Z,true,", - "1997-01-01T08:00:00.003Z,true,", + "1970-01-01T00:00:00.000Z,false,", + "1970-01-01T00:00:00.001Z,false,", + "1970-01-01T00:00:00.002Z,true,", + "1970-01-01T00:00:00.003Z,true,", }; tableResultSetEqualTest( "select Time, CAST(s5 AS BOOLEAN) as cast_s5 from normal where device_id='d1'", @@ -548,10 +548,10 @@ public class IoTDBCastFunctionIT { // cast to text String[] stringRetArray = new String[] { - "1997-01-01T08:00:00.000Z,false,", - "1997-01-01T08:00:00.001Z,false,", - "1997-01-01T08:00:00.002Z,true,", - "1997-01-01T08:00:00.003Z,true,", + "1970-01-01T00:00:00.000Z,false,", + "1970-01-01T00:00:00.001Z,false,", + "1970-01-01T00:00:00.002Z,true,", + "1970-01-01T00:00:00.003Z,true,", }; tableResultSetEqualTest( "select Time, CAST(s5 AS STRING) as cast_s5 from normal where device_id='d1'", @@ -566,7 +566,7 @@ public class IoTDBCastFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "cast_s6"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.000Z,10000,", "1997-01-01T08:00:00.001Z,3,", + "1970-01-01T00:00:00.000Z,10000,", "1970-01-01T00:00:00.001Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s6 AS INT32) as cast_s6 from normal where device_id='d1' and Time < 2", @@ -577,7 +577,7 @@ public class IoTDBCastFunctionIT { // cast to long String[] longRetArray = new String[] { - "1997-01-01T08:00:00.000Z,10000,", "1997-01-01T08:00:00.001Z,3,", + "1970-01-01T00:00:00.000Z,10000,", "1970-01-01T00:00:00.001Z,3,", }; tableResultSetEqualTest( "select Time, CAST(s6 AS INT64) as cast_s6 from normal where device_id='d1' and Time < 2", @@ -588,7 +588,7 @@ public class IoTDBCastFunctionIT { // cast to float String[] floatRetArray = new String[] { - "1997-01-01T08:00:00.000Z,10000.0,", "1997-01-01T08:00:00.001Z,3.0,", + "1970-01-01T00:00:00.000Z,10000.0,", "1970-01-01T00:00:00.001Z,3.0,", }; tableResultSetEqualTest( "select Time, CAST(s6 AS FLOAT) as cast_s6 from normal where device_id='d1' and Time < 2", @@ -599,7 +599,7 @@ public class IoTDBCastFunctionIT { // cast to double String[] doubleRetArray = new String[] { - "1997-01-01T08:00:00.000Z,10000.0,", "1997-01-01T08:00:00.001Z,3.0,", + "1970-01-01T00:00:00.000Z,10000.0,", "1970-01-01T00:00:00.001Z,3.0,", }; tableResultSetEqualTest( "select Time, CAST(s6 AS DOUBLE) as cast_s6 from normal where device_id='d1' and Time < 2", @@ -610,7 +610,7 @@ public class IoTDBCastFunctionIT { // cast to boolean String[] booleanRetArray = new String[] { - "1997-01-01T08:00:00.002Z,true,", "1997-01-01T08:00:00.003Z,false,", + "1970-01-01T00:00:00.002Z,true,", "1970-01-01T00:00:00.003Z,false,", }; tableResultSetEqualTest( "select Time, CAST(s6 AS BOOLEAN) as cast_s6 from normal where device_id='d1' and Time >= 2", @@ -621,8 +621,8 @@ public class IoTDBCastFunctionIT { // cast to text String[] stringRetArray = new String[] { - "1997-01-01T08:00:00.000Z,10000,", "1997-01-01T08:00:00.001Z,3,", - "1997-01-01T08:00:00.002Z,TRue,", "1997-01-01T08:00:00.003Z,faLse,", + "1970-01-01T00:00:00.000Z,10000,", "1970-01-01T00:00:00.001Z,3,", + "1970-01-01T00:00:00.002Z,TRue,", "1970-01-01T00:00:00.003Z,faLse,", }; tableResultSetEqualTest( "select Time, CAST(s6 AS STRING) as cast_s6 from normal where device_id='d1'", @@ -653,7 +653,7 @@ public class IoTDBCastFunctionIT { @Test public void testCastWithFloatSource() { - try (Connection connection = EnvFactory.getEnv().getConnection(); + try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT); Statement statement = connection.createStatement()) { try { statement.execute("USE " + DATABASE_NAME); @@ -676,7 +676,7 @@ public class IoTDBCastFunctionIT { @Test public void testCastWithDoubleSource() { - try (Connection connection = EnvFactory.getEnv().getConnection(); + try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT); Statement statement = connection.createStatement()) { try { statement.execute("USE " + DATABASE_NAME); @@ -706,7 +706,7 @@ public class IoTDBCastFunctionIT { @Test public void testCastWithTextSource() { - try (Connection connection = EnvFactory.getEnv().getConnection(); + try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT); Statement statement = connection.createStatement()) { statement.execute("USE " + DATABASE_NAME); try { diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunctionIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunctionIT.java index 4cc357351aa..3d63a419f96 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunctionIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBDiffFunctionIT.java @@ -34,7 +34,7 @@ import org.junit.runner.RunWith; import java.sql.Connection; import java.sql.Statement; -import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest; +import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest; @RunWith(IoTDBTestRunner.class) @Category({LocalStandaloneIT.class, ClusterIT.class}) @@ -47,7 +47,7 @@ public class IoTDBDiffFunctionIT { new String[] { "CREATE DATABASE " + DATABASE_NAME, "use " + DATABASE_NAME, - "create table table1(device_id STRING ID, s1 INT32 MEASUREMENT, s2 INT32 MEASUREMENT);", + "create table table1(device_id STRING ID, s1 INT32 MEASUREMENT, s2 INT32 MEASUREMENT)", "INSERT INTO table1(time,device_id,s1,s2) values(1, 'd1', 1, 1)", "INSERT INTO table1(time,device_id,s1) values(2, 'd1', 2)", "INSERT INTO table1(time,device_id,s2) values(3, 'd1', 3)", @@ -92,62 +92,65 @@ public class IoTDBDiffFunctionIT { String[] expectedHeader = new String[] {"time", "_col1", "_col2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,null,null,", - "1997-01-01T08:00:00.002Z,1.0,null,", - "1997-01-01T08:00:00.003Z,null,2.0,", - "1997-01-01T08:00:00.004Z,2.0,null,", - "1997-01-01T08:00:00.005Z,1.0,2.0,", - "1997-01-01T08:00:00.006Z,null,1.0,", + "1970-01-01T00:00:00.001Z,null,null,", + "1970-01-01T00:00:00.002Z,1.0,null,", + "1970-01-01T00:00:00.003Z,null,2.0,", + "1970-01-01T00:00:00.004Z,2.0,null,", + "1970-01-01T00:00:00.005Z,1.0,2.0,", + "1970-01-01T00:00:00.006Z,null,1.0,", "1970-02-27T20:53:20.000Z,null,1.0,", "1970-02-27T20:53:20.001Z,3.0,null," }; - resultSetEqualTest( + tableResultSetEqualTest( "select time,diff(s1), diff(s2) from table1 where device_id='d1'", expectedHeader, - retArray); + retArray, + DATABASE_NAME); // align by device expectedHeader = new String[] {"time", "device_id", "_col1", "_col2"}; retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,null,null,", - "1997-01-01T08:00:00.002Z,d1,1.0,null,", - "1997-01-01T08:00:00.003Z,d1,null,2.0,", - "1997-01-01T08:00:00.004Z,d1,2.0,null,", - "1997-01-01T08:00:00.005Z,d1,1.0,2.0,", - "1997-01-01T08:00:00.006Z,d1,null,1.0,", + "1970-01-01T00:00:00.001Z,d1,null,null,", + "1970-01-01T00:00:00.002Z,d1,1.0,null,", + "1970-01-01T00:00:00.003Z,d1,null,2.0,", + "1970-01-01T00:00:00.004Z,d1,2.0,null,", + "1970-01-01T00:00:00.005Z,d1,1.0,2.0,", + "1970-01-01T00:00:00.006Z,d1,null,1.0,", "1970-02-27T20:53:20.000Z,d1,null,1.0,", "1970-02-27T20:53:20.001Z,d1,3.0,null,", - "1997-01-01T08:00:00.001Z,d2,-7.0,-6.0", - "1997-01-01T08:00:00.002Z,d2,1.0,1.0,", + "1970-01-01T00:00:00.001Z,d2,-7.0,-6.0", + "1970-01-01T00:00:00.002Z,d2,1.0,1.0,", "1970-02-27T20:53:20.000Z,d2,null,1.0,", "1970-02-27T20:53:20.001Z,d2,2.0,null,", }; - resultSetEqualTest( + tableResultSetEqualTest( "select time, device_id, Diff(s1), diff(s2) from table1 where device_id='d1' or device_id='d2' order by device_id", expectedHeader, - retArray); + retArray, + DATABASE_NAME); // align by device + order by time retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,null,null,", - "1997-01-01T08:00:00.001Z,d2,null,null", - "1997-01-01T08:00:00.002Z,d1,1.0,null,", - "1997-01-01T08:00:00.002Z,d2,1.0,1.0,", - "1997-01-01T08:00:00.003Z,d1,null,2.0,", - "1997-01-01T08:00:00.004Z,d1,2.0,null,", - "1997-01-01T08:00:00.005Z,d1,1.0,2.0,", - "1997-01-01T08:00:00.006Z,d1,null,1.0,", + "1970-01-01T00:00:00.001Z,d1,null,null,", + "1970-01-01T00:00:00.001Z,d2,null,null", + "1970-01-01T00:00:00.002Z,d1,1.0,null,", + "1970-01-01T00:00:00.002Z,d2,1.0,1.0,", + "1970-01-01T00:00:00.003Z,d1,null,2.0,", + "1970-01-01T00:00:00.004Z,d1,2.0,null,", + "1970-01-01T00:00:00.005Z,d1,1.0,2.0,", + "1970-01-01T00:00:00.006Z,d1,null,1.0,", "1970-02-27T20:53:20.000Z,d1,null,1.0,", "1970-02-27T20:53:20.000Z,d2,null,1.0,", "1970-02-27T20:53:20.001Z,d1,3.0,null,", "1970-02-27T20:53:20.001Z,d2,2.0,null,", }; - resultSetEqualTest( + tableResultSetEqualTest( "select time, device_id, Diff(s1), diff(s2) from table1 where device_id='d1' or device_id='d2' order by time,device_id", expectedHeader, - retArray); + retArray, + DATABASE_NAME); } @Test @@ -155,62 +158,65 @@ public class IoTDBDiffFunctionIT { String[] expectedHeader = new String[] {"time", "_col1", "_col2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,null,null,", - "1997-01-01T08:00:00.002Z,1.0,null,", - "1997-01-01T08:00:00.003Z,null,null,", - "1997-01-01T08:00:00.004Z,null,null,", - "1997-01-01T08:00:00.005Z,1.0,null,", - "1997-01-01T08:00:00.006Z,null,1.0,", + "1970-01-01T00:00:00.001Z,null,null,", + "1970-01-01T00:00:00.002Z,1.0,null,", + "1970-01-01T00:00:00.003Z,null,null,", + "1970-01-01T00:00:00.004Z,null,null,", + "1970-01-01T00:00:00.005Z,1.0,null,", + "1970-01-01T00:00:00.006Z,null,1.0,", "1970-02-27T20:53:20.000Z,null,1.0,", "1970-02-27T20:53:20.001Z,null,null," }; - resultSetEqualTest( + tableResultSetEqualTest( "select time, Diff(s1, false), diff(s2, false) from table1 where device_id='d1'", expectedHeader, - retArray); + retArray, + DATABASE_NAME); // align by device expectedHeader = new String[] {"time", "device_id", "_col1", "_col2"}; retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,null,null,", - "1997-01-01T08:00:00.002Z,d1,1.0,null,", - "1997-01-01T08:00:00.003Z,d1,null,null,", - "1997-01-01T08:00:00.004Z,d1,null,null,", - "1997-01-01T08:00:00.005Z,d1,1.0,null,", - "1997-01-01T08:00:00.006Z,d1,null,1.0,", + "1970-01-01T00:00:00.001Z,d1,null,null,", + "1970-01-01T00:00:00.002Z,d1,1.0,null,", + "1970-01-01T00:00:00.003Z,d1,null,null,", + "1970-01-01T00:00:00.004Z,d1,null,null,", + "1970-01-01T00:00:00.005Z,d1,1.0,null,", + "1970-01-01T00:00:00.006Z,d1,null,1.0,", "1970-02-27T20:53:20.000Z,d1,null,1.0,", "1970-02-27T20:53:20.001Z,d1,null,null,", - "1997-01-01T08:00:00.001Z,d2,null,null", - "1997-01-01T08:00:00.002Z,d2,1.0,1.0,", + "1970-01-01T00:00:00.001Z,d2,null,null", + "1970-01-01T00:00:00.002Z,d2,1.0,1.0,", "1970-02-27T20:53:20.000Z,d2,null,1.0,", "1970-02-27T20:53:20.001Z,d2,null,null,", }; - resultSetEqualTest( + tableResultSetEqualTest( "select time, device_id, Diff(s1, false), diff(s2, false) from table1 where device_id='d1' or device_id='d2' order by device_id", expectedHeader, - retArray); + retArray, + DATABASE_NAME); // align by device + order by time retArray = new String[] { - "1997-01-01T08:00:00.001Z,d1,null,null,", - "1997-01-01T08:00:00.001Z,d2,null,null", - "1997-01-01T08:00:00.002Z,d1,1.0,null,", - "1997-01-01T08:00:00.002Z,d2,1.0,1.0,", - "1997-01-01T08:00:00.003Z,d1,null,null,", - "1997-01-01T08:00:00.004Z,d1,null,null,", - "1997-01-01T08:00:00.005Z,d1,1.0,null,", - "1997-01-01T08:00:00.006Z,d1,null,1.0,", + "1970-01-01T00:00:00.001Z,d1,null,null,", + "1970-01-01T00:00:00.001Z,d2,null,null", + "1970-01-01T00:00:00.002Z,d1,1.0,null,", + "1970-01-01T00:00:00.002Z,d2,1.0,1.0,", + "1970-01-01T00:00:00.003Z,d1,null,null,", + "1970-01-01T00:00:00.004Z,d1,null,null,", + "1970-01-01T00:00:00.005Z,d1,1.0,null,", + "1970-01-01T00:00:00.006Z,d1,null,1.0,", "1970-02-27T20:53:20.000Z,d1,null,1.0,", "1970-02-27T20:53:20.000Z,d2,null,1.0,", "1970-02-27T20:53:20.001Z,d1,null,null,", "1970-02-27T20:53:20.001Z,d2,null,null,", }; - resultSetEqualTest( + tableResultSetEqualTest( "select time, device_id, Diff(s1, false), diff(s2, false) where device_id='d1' or device_id='d2' order by time,device_id", expectedHeader, - retArray); + retArray, + DATABASE_NAME); } @Test @@ -218,13 +224,14 @@ public class IoTDBDiffFunctionIT { String[] expectedHeader = new String[] {"time", "s1", "s2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.002Z,2,null,", - "1997-01-01T08:00:00.004Z,4,null,", - "1997-01-01T08:00:00.005Z,5,5.0," + "1970-01-01T00:00:00.002Z,2,null,", + "1970-01-01T00:00:00.004Z,4,null,", + "1970-01-01T00:00:00.005Z,5,5.0," }; - resultSetEqualTest( + tableResultSetEqualTest( "select time, s1, s2 from table1 where device_id='d1' and diff(s1) between 1 and 2", expectedHeader, - retArray); + retArray, + DATABASE_NAME); } } diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBReplaceFunctionIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBReplaceFunctionIT.java index d16ce0311be..25e0351ce42 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBReplaceFunctionIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBReplaceFunctionIT.java @@ -48,12 +48,12 @@ public class IoTDBReplaceFunctionIT { new String[] { "CREATE DATABASE " + DATABASE_NAME, "use " + DATABASE_NAME, - "create table table1(device_id STRING ID, s1 TEXT MEASUREMENT, s2 INT32 MEASUREMENT, s3 INT64 MEASUREMENT, s4 FLOAT MEASUREMENT, s5 DOUBLE MEASUREMENT, s6 BOOLEAN MEASUREMENT, s7 DATE MEASUREMENT, s8 TIMESTAMP MEASUREMENT, s9 STRING MEASUREMENT, s10 BLOB MEASUREMENT);", - "INSERT INTO table1(Time,device_id,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10) values(1, 'd1', 'abcd', 1, 1, 1, 1, true, '2021-10-01', 1633046400000, 'abcd', X'abcd')", - "INSERT INTO table1(Time,device_id,s1) values(2, 'd1', 'test\\\\')", - "INSERT INTO table1(Time,device_id,s1) values(3, 'd1', 'abcd\\\\')", - "INSERT INTO table1(Time,device_id,s9)) values(2, 'd1', 'test\\\\')", - "INSERT INTO table1(Time,device_id,s9)) values(3, 'd1', 'abcd\\\\')", + "create table table1(device_id STRING ID, s1 TEXT MEASUREMENT, s2 INT32 MEASUREMENT, s3 INT64 MEASUREMENT, s4 FLOAT MEASUREMENT, s5 DOUBLE MEASUREMENT, s6 BOOLEAN MEASUREMENT, s7 DATE MEASUREMENT, s8 TIMESTAMP MEASUREMENT, s9 STRING MEASUREMENT)", + "INSERT INTO table1(time,device_id,s1,s2,s3,s4,s5,s6,s7,s8,s9) values(1, 'd1', 'abcd', 1, 1, 1, 1, true, '2021-10-01', 1633046400000, 'abcd')", + "INSERT INTO table1(time,device_id,s1) values(2, 'd1', 'test\\\\')", + "INSERT INTO table1(time,device_id,s1) values(3, 'd1', 'abcd\\\\')", + "INSERT INTO table1(time,device_id,s9) values(2, 'd1', 'test\\\\')", + "INSERT INTO table1(time,device_id,s9) values(3, 'd1', 'abcd\\\\')", "flush" }; @@ -72,6 +72,7 @@ public class IoTDBReplaceFunctionIT { } } catch (Exception e) { e.printStackTrace(); + fail(e.getMessage()); } } @@ -85,9 +86,9 @@ public class IoTDBReplaceFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "_col1", "_col2"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,ABcd,abcd,", - "1997-01-01T08:00:00.002Z,test\\\\,testaa,", - "1997-01-01T08:00:00.003Z,ABcd\\\\,abcdaa," + "1970-01-01T00:00:00.001Z,ABcd,abcd,", + "1970-01-01T00:00:00.002Z,test\\\\,testaa,", + "1970-01-01T00:00:00.003Z,ABcd\\\\,abcdaa," }; tableResultSetEqualTest( "select Time, REPLACE(s1, 'ab', 'AB'), REPLACE(s1, '\\', 'a') from table1", @@ -97,9 +98,9 @@ public class IoTDBReplaceFunctionIT { String[] retArray2 = new String[] { - "1997-01-01T08:00:00.001Z,ABcd,abcd,", - "1997-01-01T08:00:00.002Z,test\\\\,testaa,", - "1997-01-01T08:00:00.003Z,ABcd\\\\,abcdaa," + "1970-01-01T00:00:00.001Z,ABcd,abcd,", + "1970-01-01T00:00:00.002Z,test\\\\,testaa,", + "1970-01-01T00:00:00.003Z,ABcd\\\\,abcdaa," }; tableResultSetEqualTest( "select Time, REPLACE(s9, 'ab', 'AB'), REPLACE(s9, '\\', 'a') from table1", @@ -113,9 +114,9 @@ public class IoTDBReplaceFunctionIT { String[] expectedHeader = new String[] {TIMESTAMP_STR, "_col1"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,acd,", - "1997-01-01T08:00:00.002Z,test\\\\,", - "1997-01-01T08:00:00.003Z,acd\\\\," + "1970-01-01T00:00:00.001Z,acd,", + "1970-01-01T00:00:00.002Z,test\\\\,", + "1970-01-01T00:00:00.003Z,acd\\\\," }; tableResultSetEqualTest( "select Time, REPLACE(s1, 'b') from table1", expectedHeader, retArray, DATABASE_NAME); @@ -168,11 +169,11 @@ public class IoTDBReplaceFunctionIT { } catch (Exception ignored) { } - try { - statement.execute("select REPLACE(s10, 'a', 'b') from table1"); - fail(); - } catch (Exception ignored) { - } + // try { + // statement.execute("select REPLACE(s10, 'a', 'b') from table1"); + // fail(); + // } catch (Exception ignored) { + // } } catch (SQLException e) { e.printStackTrace(); diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBRoundFunctionIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBRoundFunctionIT.java index a3986167d3d..2fe37d04ad2 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBRoundFunctionIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBRoundFunctionIT.java @@ -37,6 +37,7 @@ import java.sql.Statement; import static org.apache.iotdb.db.it.utils.TestUtils.tableAssertTestFail; import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest; +import static org.junit.Assert.fail; @RunWith(IoTDBTestRunner.class) @Category({LocalStandaloneIT.class, ClusterIT.class}) @@ -48,7 +49,7 @@ public class IoTDBRoundFunctionIT { new String[] { "CREATE DATABASE " + DATABASE_NAME, "use " + DATABASE_NAME, - "create table table1(device_id STRING ID s1 INT32 MEASUREMENT, s2 INT64 MEASUREMENT, s3 DOUBLE MEASUREMENT, s4 FLOAT MEASUREMENT, s5 BOOLEAN MEASUREMENT, s6 STRING MEASUREMENT)", + "create table table1(device_id STRING ID, s1 INT32 MEASUREMENT, s2 INT64 MEASUREMENT, s3 DOUBLE MEASUREMENT, s4 FLOAT MEASUREMENT, s5 BOOLEAN MEASUREMENT, s6 STRING MEASUREMENT)", "INSERT INTO table1(time,device_id,s1,s2,s3,s4,s5,s6) values(1, 'd1', 2, 3, 0.11234, 101.143445345,true,null)", "INSERT INTO table1(time,device_id,s1,s2,s3,s4,s5,s6) values(2, 'd1', 2, 4, 10.11234, 20.1443465345,true,'sss')", "INSERT INTO table1(time,device_id,s1,s2,s3,s4,s5,s6) values(3, 'd1', 2, 555, 120.161234, 20.61437245345,true,'sss')", @@ -75,6 +76,7 @@ public class IoTDBRoundFunctionIT { } } catch (Exception e) { e.printStackTrace(); + fail(e.getMessage()); } } @@ -88,25 +90,25 @@ public class IoTDBRoundFunctionIT { String[] expectedHeader = new String[] {"time", "_col1"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,2.0,", - "1997-01-01T08:00:00.002Z,2.0,", - "1997-01-01T08:00:00.003Z,2.0,", - "1997-01-01T08:00:00.004Z,2.0,", - "1997-01-01T08:00:00.005Z,2.0,", - "1997-01-01T08:00:00.006Z,2.0,", - "2023-03-13T08:16:19.764Z,2.0" + "1970-01-01T00:00:00.001Z,2.0,", + "1970-01-01T00:00:00.002Z,2.0,", + "1970-01-01T00:00:00.003Z,2.0,", + "1970-01-01T00:00:00.004Z,2.0,", + "1970-01-01T00:00:00.005Z,2.0,", + "1970-01-01T00:00:00.006Z,2.0,", + "2023-03-13T08:16:19.764Z,2.0," }; tableResultSetEqualTest( "select time, round(s1) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,3.0,", - "1997-01-01T08:00:00.002Z,4.0,", - "1997-01-01T08:00:00.003Z,555.0,", - "1997-01-01T08:00:00.004Z,1.2341234E7,", - "1997-01-01T08:00:00.005Z,55678.0,", - "1997-01-01T08:00:00.006Z,12355.0,", + "1970-01-01T00:00:00.001Z,3.0,", + "1970-01-01T00:00:00.002Z,4.0,", + "1970-01-01T00:00:00.003Z,555.0,", + "1970-01-01T00:00:00.004Z,1.2341234E7,", + "1970-01-01T00:00:00.005Z,55678.0,", + "1970-01-01T00:00:00.006Z,12355.0,", "2023-03-13T08:16:19.764Z,12345.0," }; tableResultSetEqualTest( @@ -114,11 +116,11 @@ public class IoTDBRoundFunctionIT { intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.0,", - "1997-01-01T08:00:00.002Z,10.0,", - "1997-01-01T08:00:00.003Z,120.0,", - "1997-01-01T08:00:00.004Z,101.0,", - "1997-01-01T08:00:00.005Z,90.0,", + "1970-01-01T00:00:00.001Z,0.0,", + "1970-01-01T00:00:00.002Z,10.0,", + "1970-01-01T00:00:00.003Z,120.0,", + "1970-01-01T00:00:00.004Z,101.0,", + "1970-01-01T00:00:00.005Z,90.0,", "2023-03-13T08:16:19.764Z,121.0," }; tableResultSetEqualTest( @@ -126,11 +128,11 @@ public class IoTDBRoundFunctionIT { intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,101.0,", - "1997-01-01T08:00:00.002Z,20.0,", - "1997-01-01T08:00:00.003Z,21.0,", - "1997-01-01T08:00:00.005Z,21.0,", - "1997-01-01T08:00:00.006Z,61.0,", + "1970-01-01T00:00:00.001Z,101.0,", + "1970-01-01T00:00:00.002Z,20.0,", + "1970-01-01T00:00:00.003Z,21.0,", + "1970-01-01T00:00:00.005Z,21.0,", + "1970-01-01T00:00:00.006Z,61.0,", "2023-03-13T08:16:19.764Z,10.0," }; tableResultSetEqualTest( @@ -142,101 +144,101 @@ public class IoTDBRoundFunctionIT { String[] expectedHeader = new String[] {"time", "_col1"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,2.0,", - "1997-01-01T08:00:00.002Z,2.0,", - "1997-01-01T08:00:00.003Z,2.0,", - "1997-01-01T08:00:00.004Z,2.0,", - "1997-01-01T08:00:00.005Z,2.0,", - "1997-01-01T08:00:00.006Z,2.0,", - "2023-03-13T08:16:19.764Z,2.0" + "1970-01-01T00:00:00.001Z,2.0,", + "1970-01-01T00:00:00.002Z,2.0,", + "1970-01-01T00:00:00.003Z,2.0,", + "1970-01-01T00:00:00.004Z,2.0,", + "1970-01-01T00:00:00.005Z,2.0,", + "1970-01-01T00:00:00.006Z,2.0,", + "2023-03-13T08:16:19.764Z,2.0," }; tableResultSetEqualTest( "select time, round(s1, 1) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,3.0,", - "1997-01-01T08:00:00.002Z,4.0,", - "1997-01-01T08:00:00.003Z,555.0,", - "1997-01-01T08:00:00.004Z,1.2341234E7,", - "1997-01-01T08:00:00.005Z,55678.0,", - "1997-01-01T08:00:00.006Z,12355.0,", - "2023-03-13T08:16:19.764Z,12345.0" + "1970-01-01T00:00:00.001Z,3.0,", + "1970-01-01T00:00:00.002Z,4.0,", + "1970-01-01T00:00:00.003Z,555.0,", + "1970-01-01T00:00:00.004Z,1.2341234E7,", + "1970-01-01T00:00:00.005Z,55678.0,", + "1970-01-01T00:00:00.006Z,12355.0,", + "2023-03-13T08:16:19.764Z,12345.0," }; tableResultSetEqualTest( "select time, round(s2, 1) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.1,", - "1997-01-01T08:00:00.002Z,10.1,", - "1997-01-01T08:00:00.003Z,120.2,", - "1997-01-01T08:00:00.004Z,101.1,", - "1997-01-01T08:00:00.005Z,90.1,", - "2023-03-13T08:16:19.764Z,120.5" + "1970-01-01T00:00:00.001Z,0.1,", + "1970-01-01T00:00:00.002Z,10.1,", + "1970-01-01T00:00:00.003Z,120.2,", + "1970-01-01T00:00:00.004Z,101.1,", + "1970-01-01T00:00:00.005Z,90.1,", + "2023-03-13T08:16:19.764Z,120.5," }; tableResultSetEqualTest( "select time, round(s3, 1) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.11,", - "1997-01-01T08:00:00.002Z,10.11,", - "1997-01-01T08:00:00.003Z,120.16,", - "1997-01-01T08:00:00.004Z,101.13,", - "1997-01-01T08:00:00.005Z,90.12,", - "2023-03-13T08:16:19.764Z,120.51" + "1970-01-01T00:00:00.001Z,0.11,", + "1970-01-01T00:00:00.002Z,10.11,", + "1970-01-01T00:00:00.003Z,120.16,", + "1970-01-01T00:00:00.004Z,101.13,", + "1970-01-01T00:00:00.005Z,90.12,", + "2023-03-13T08:16:19.764Z,120.51," }; tableResultSetEqualTest( - "select time, round(s4, 1) from table1", expectedHeader, intRetArray, DATABASE_NAME); + "select time, round(s3, 2) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.112,", - "1997-01-01T08:00:00.002Z,10.112,", - "1997-01-01T08:00:00.003Z,120.161,", - "1997-01-01T08:00:00.004Z,101.131,", - "1997-01-01T08:00:00.005Z,90.116,", - "2023-03-13T08:16:19.764Z,120.511" + "1970-01-01T00:00:00.001Z,0.112,", + "1970-01-01T00:00:00.002Z,10.112,", + "1970-01-01T00:00:00.003Z,120.161,", + "1970-01-01T00:00:00.004Z,101.131,", + "1970-01-01T00:00:00.005Z,90.116,", + "2023-03-13T08:16:19.764Z,120.511," }; tableResultSetEqualTest( "select time, round(s3, 3) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.1123,", - "1997-01-01T08:00:00.002Z,10.1123,", - "1997-01-01T08:00:00.003Z,120.1612,", - "1997-01-01T08:00:00.004Z,101.1312,", - "1997-01-01T08:00:00.005Z,90.1162,", - "2023-03-13T08:16:19.764Z,102.5112" + "1970-01-01T00:00:00.001Z,0.1123,", + "1970-01-01T00:00:00.002Z,10.1123,", + "1970-01-01T00:00:00.003Z,120.1612,", + "1970-01-01T00:00:00.004Z,101.1312,", + "1970-01-01T00:00:00.005Z,90.1162,", + "2023-03-13T08:16:19.764Z,120.5112," }; tableResultSetEqualTest( "select time, round(s3, 4) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,101.14345,", - "1997-01-01T08:00:00.002Z,20.14435,", - "1997-01-01T08:00:00.003Z,20.61437,", - "1997-01-01T08:00:00.005Z,20.81435,", - "1997-01-01T08:00:00.006Z,60.71443,", - "2023-03-13T08:16:19.764Z,10.14342" + "1970-01-01T00:00:00.001Z,101.14345,", + "1970-01-01T00:00:00.002Z,20.14435,", + "1970-01-01T00:00:00.003Z,20.61437,", + "1970-01-01T00:00:00.005Z,20.81435,", + "1970-01-01T00:00:00.006Z,60.71443,", + "2023-03-13T08:16:19.764Z,10.14342," }; tableResultSetEqualTest( "select time, round(s4, 5) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,101.1,", - "1997-01-01T08:00:00.002Z,20.1,", - "1997-01-01T08:00:00.003Z,20.6,", - "1997-01-01T08:00:00.005Z,20.8,", - "1997-01-01T08:00:00.006Z,60.7,", - "2023-03-13T08:16:19.764Z,10.1" + "1970-01-01T00:00:00.001Z,101.1,", + "1970-01-01T00:00:00.002Z,20.1,", + "1970-01-01T00:00:00.003Z,20.6,", + "1970-01-01T00:00:00.005Z,20.8,", + "1970-01-01T00:00:00.006Z,60.7,", + "2023-03-13T08:16:19.764Z,10.1," }; tableResultSetEqualTest( - "select time, round(4, 1) from table1", expectedHeader, intRetArray, DATABASE_NAME); + "select time, round(s4, 1) from table1", expectedHeader, intRetArray, DATABASE_NAME); } @Test @@ -245,25 +247,25 @@ public class IoTDBRoundFunctionIT { String[] expectedHeader = new String[] {"time", "_col1"}; String[] intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.0,", - "1997-01-01T08:00:00.002Z,0.0,", - "1997-01-01T08:00:00.003Z,0.0,", - "1997-01-01T08:00:00.004Z,0.0,", - "1997-01-01T08:00:00.005Z,0.0,", - "1997-01-01T08:00:00.006Z,0.0,", - "2023-03-13T08:16:19.764Z,0.0" + "1970-01-01T00:00:00.001Z,0.0,", + "1970-01-01T00:00:00.002Z,0.0,", + "1970-01-01T00:00:00.003Z,0.0,", + "1970-01-01T00:00:00.004Z,0.0,", + "1970-01-01T00:00:00.005Z,0.0,", + "1970-01-01T00:00:00.006Z,0.0,", + "2023-03-13T08:16:19.764Z,0.0," }; tableResultSetEqualTest( "select time, round(s1, -1) from table1", expectedHeader, intRetArray, DATABASE_NAME); intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.0,", - "1997-01-01T08:00:00.002Z,0.0,", - "1997-01-01T08:00:00.003Z,560.0,", - "1997-01-01T08:00:00.004Z,1.234123E7,", - "1997-01-01T08:00:00.005Z,55680.0,", - "1997-01-01T08:00:00.006Z,12360.0,", + "1970-01-01T00:00:00.001Z,0.0,", + "1970-01-01T00:00:00.002Z,0.0,", + "1970-01-01T00:00:00.003Z,560.0,", + "1970-01-01T00:00:00.004Z,1.234123E7,", + "1970-01-01T00:00:00.005Z,55680.0,", + "1970-01-01T00:00:00.006Z,12360.0,", "2023-03-13T08:16:19.764Z,12340.0," }; tableResultSetEqualTest( @@ -271,11 +273,11 @@ public class IoTDBRoundFunctionIT { intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,0.0,", - "1997-01-01T08:00:00.002Z,10.0,", - "1997-01-01T08:00:00.003Z,120.0,", - "1997-01-01T08:00:00.004Z,100.0,", - "1997-01-01T08:00:00.005Z,90.0,", + "1970-01-01T00:00:00.001Z,0.0,", + "1970-01-01T00:00:00.002Z,10.0,", + "1970-01-01T00:00:00.003Z,120.0,", + "1970-01-01T00:00:00.004Z,100.0,", + "1970-01-01T00:00:00.005Z,90.0,", "2023-03-13T08:16:19.764Z,120.0," }; tableResultSetEqualTest( @@ -283,11 +285,11 @@ public class IoTDBRoundFunctionIT { intRetArray = new String[] { - "1997-01-01T08:00:00.001Z,100.0,", - "1997-01-01T08:00:00.002Z,20.0,", - "1997-01-01T08:00:00.003Z,20.0,", - "1997-01-01T08:00:00.005Z,20.0,", - "1997-01-01T08:00:00.006Z,60.0,", + "1970-01-01T00:00:00.001Z,100.0,", + "1970-01-01T00:00:00.002Z,20.0,", + "1970-01-01T00:00:00.003Z,20.0,", + "1970-01-01T00:00:00.005Z,20.0,", + "1970-01-01T00:00:00.006Z,60.0,", "2023-03-13T08:16:19.764Z,10.0," }; tableResultSetEqualTest( diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionIT.java index b021d75fb81..ba19a52a937 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBSubStringFunctionIT.java @@ -48,8 +48,15 @@ public class IoTDBSubStringFunctionIT { new String[] { "CREATE DATABASE " + DATABASE_NAME, "use " + DATABASE_NAME, - "create table table1(device_id STRING ID, s1 TEXT MEASUREMENT, s2 INT32 MEASUREMENT, s3 INT64 MEASUREMENT, s4 FLOAT MEASUREMENT, s5 DOUBLE MEASUREMENT, s6 BOOLEAN MEASUREMENT, s7 DATE MEASUREMENT, s8 TIMESTAMP MEASUREMENT, s9 STRING MEASUREMENT, s10 BLOB MEASUREMENT);", - "INSERT INTO table1(Time,device_id,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10) values(1, 'd1', 'abcd', 1, 1, 1, 1, true, '2021-10-01', 1633046400000, 'abcd', X'abcd')", + // "create table table1(device_id STRING ID, s1 TEXT MEASUREMENT, s2 INT32 + // MEASUREMENT, s3 INT64 MEASUREMENT, s4 FLOAT MEASUREMENT, s5 DOUBLE MEASUREMENT, s6 + // BOOLEAN MEASUREMENT, s7 DATE MEASUREMENT, s8 TIMESTAMP MEASUREMENT, s9 STRING + // MEASUREMENT, s10 BLOB MEASUREMENT)", + // "INSERT INTO table1(Time,device_id,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10) values(1, + // 'd1', 'abcd', 1, 1, 1, 1, true, '2021-10-01', 1633046400000, 'abcd', X'abcd')", + + "create table table1(device_id STRING ID, s1 TEXT MEASUREMENT, s2 INT32 MEASUREMENT, s3 INT64 MEASUREMENT, s4 FLOAT MEASUREMENT, s5 DOUBLE MEASUREMENT, s6 BOOLEAN MEASUREMENT, s7 DATE MEASUREMENT, s8 TIMESTAMP MEASUREMENT, s9 STRING MEASUREMENT)", + "INSERT INTO table1(Time,device_id,s1,s2,s3,s4,s5,s6,s7,s8,s9) values(1, 'd1', 'abcd', 1, 1, 1, 1, true, '2021-10-01', 1633046400000, 'abcd')", "INSERT INTO table1(Time,device_id,s1) values(2, 'd1', 'test')", "INSERT INTO table1(Time,device_id,s1) values(3, 'd1', 'abcdefg')", "INSERT INTO table1(Time,device_id,s9) values(2, 'd1', 'test')", @@ -83,12 +90,12 @@ public class IoTDBSubStringFunctionIT { @Test public void testNewTransformer() { // Normal - String[] expectedHeader = new String[] {"time", "s1", "_col1", "_col2"}; + String[] expectedHeader = new String[] {"time", "s1", "_col2", "_col3"}; String[] retArray = new String[] { - "1997-01-01T08:00:00.001Z,abcd,abcd,abc,", - "1997-01-01T08:00:00.002Z,test,test,tes,", - "1997-01-01T08:00:00.003Z,abcdefg,abcdefg,abc,", + "1970-01-01T00:00:00.001Z,abcd,abcd,abc,", + "1970-01-01T00:00:00.002Z,test,test,tes,", + "1970-01-01T00:00:00.003Z,abcdefg,abcdefg,abc,", }; tableResultSetEqualTest( "select time,s1,SUBSTRING(s1 FROM 1),SUBSTRING(s1 FROM 1 FOR 3) from table1", @@ -99,9 +106,9 @@ public class IoTDBSubStringFunctionIT { // Param 1 greater than input series length retArray = new String[] { - "1997-01-01T08:00:00.001Z,abcd,,,", - "1997-01-01T08:00:00.002Z,test,,,", - "1997-01-01T08:00:00.003Z,abcdefg,,,", + "1970-01-01T00:00:00.001Z,abcd,,,", + "1970-01-01T00:00:00.002Z,test,,,", + "1970-01-01T00:00:00.003Z,abcdefg,,,", }; tableResultSetEqualTest( "select time,s1,SUBSTRING(s1 from 11),SUBSTRING(s1 from 11 for 13) from table1", @@ -110,12 +117,12 @@ public class IoTDBSubStringFunctionIT { DATABASE_NAME); // Normal - expectedHeader = new String[] {"time", "s9", "_col1", "_col2"}; + expectedHeader = new String[] {"time", "s9", "_col2", "_col3"}; String[] retArray2 = new String[] { - "1997-01-01T08:00:00.001Z,abcd,abcd,abc,", - "1997-01-01T08:00:00.002Z,test,test,tes,", - "1997-01-01T08:00:00.003Z,abcdefg,abcdefg,abc,", + "1970-01-01T00:00:00.001Z,abcd,abcd,abc,", + "1970-01-01T00:00:00.002Z,test,test,tes,", + "1970-01-01T00:00:00.003Z,abcdefg,abcdefg,abc,", }; tableResultSetEqualTest( "select time,s9,SUBSTRING(s9 from 1),SUBSTRING(s9 from 1 for 3) from table1", @@ -181,12 +188,14 @@ public class IoTDBSubStringFunctionIT { + ": Scalar function substring only accepts two or three arguments and first must be text or string data type, second and third must be numeric data types [INT32, INT64]", DATABASE_NAME); + // TODO add back after blob support // Wrong input type - tableAssertTestFail( - "select SUBSTRING(s10 FROM 1 FOR 1) from table1", - TSStatusCode.SEMANTIC_ERROR.getStatusCode() - + ": Scalar function substring only accepts two or three arguments and first must be text or string data type, second and third must be numeric data types [INT32, INT64]", - DATABASE_NAME); + // tableAssertTestFail( + // "select SUBSTRING(s10 FROM 1 FOR 1) from table1", + // TSStatusCode.SEMANTIC_ERROR.getStatusCode() + // + ": Scalar function substring only accepts two or three arguments and first must + // be text or string data type, second and third must be numeric data types [INT32, INT64]", + // DATABASE_NAME); // Using substring with float start position tableAssertTestFail( diff --git a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java index c97a989cd9e..d7dfd63b66c 100644 --- a/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java +++ b/iotdb-client/service-rpc/src/main/java/org/apache/iotdb/rpc/IoTDBRpcDataSet.java @@ -134,7 +134,8 @@ public class IoTDBRpcDataSet { // deduplicate and map if (columnNameIndex != null) { - int deduplicatedColumnSize = (int) columnNameIndex.values().stream().distinct().count(); + int deduplicatedColumnSize = + columnNameIndex.values().stream().mapToInt(Integer::intValue).max().orElse(0) + 1; this.columnTypeDeduplicatedList = new ArrayList<>(deduplicatedColumnSize); for (int i = 0; i < deduplicatedColumnSize; i++) { columnTypeDeduplicatedList.add(null); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java index 0a6c26634da..fbc40f319ae 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java @@ -95,10 +95,12 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.stream.Collectors; import static com.google.common.base.Preconditions.checkArgument; import static java.util.Objects.requireNonNull; +import static org.apache.iotdb.commons.schema.table.column.TsTableColumnCategory.MEASUREMENT; import static org.apache.iotdb.db.queryengine.common.DataNodeEndPoints.isSameNode; import static org.apache.iotdb.db.queryengine.execution.operator.process.join.merge.MergeSortComparator.getComparatorForTable; import static org.apache.iotdb.db.queryengine.execution.operator.source.relational.TableScanOperator.constructAlignedPath; @@ -238,6 +240,18 @@ public class TableOperatorGenerator extends PlanVisitor<Operator, LocalExecution } } + Set<Symbol> outputSet = new HashSet<>(outputColumnNames); + for (Map.Entry<Symbol, ColumnSchema> entry : node.getAssignments().entrySet()) { + if (!outputSet.contains(entry.getKey()) + && entry.getValue().getColumnCategory() == MEASUREMENT) { + measurementColumnCount++; + measurementColumnNames.add(entry.getKey().getName()); + measurementSchemas.add( + new MeasurementSchema( + entry.getValue().getName(), getTSDataType(entry.getValue().getType()))); + } + } + SeriesScanOptions.Builder scanOptionsBuilder = node.getTimePredicate() .map(timePredicate -> getSeriesScanOptionsBuilder(context, timePredicate)) diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/predicate/ConvertPredicateToFilterVisitor.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/predicate/ConvertPredicateToFilterVisitor.java index 80fcf5bce87..1480601a070 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/predicate/ConvertPredicateToFilterVisitor.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/predicate/ConvertPredicateToFilterVisitor.java @@ -51,6 +51,7 @@ import org.apache.tsfile.read.filter.factory.FilterFactory; import org.apache.tsfile.read.filter.factory.ValueFilterApi; import org.apache.tsfile.read.filter.operator.ValueFilterOperators; import org.apache.tsfile.utils.Binary; +import org.apache.tsfile.utils.DateUtils; import java.util.HashMap; import java.util.HashSet; @@ -157,7 +158,10 @@ public class ConvertPredicateToFilterVisitor switch (dataType.getTypeEnum()) { case INT32: return (T) Integer.valueOf(Long.valueOf(getLongValue(value)).intValue()); + case DATE: + return (T) DateUtils.parseDateExpressionToInt(getStringValue(value)); case INT64: + case TIMESTAMP: return (T) Long.valueOf(getLongValue(value)); case FLOAT: return (T) Float.valueOf((float) getDoubleValue(value)); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionRewriter.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionRewriter.java index 022d6527dab..7708989645e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionRewriter.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionRewriter.java @@ -29,6 +29,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FieldReference; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FunctionCall; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Identifier; +import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.InListExpression; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.InPredicate; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.IsNotNullPredicate; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.IsNullPredicate; @@ -125,6 +126,11 @@ public class ExpressionRewriter<C> { return rewriteExpression(node, context, treeRewriter); } + public Expression rewriteInListExpression( + InListExpression node, C context, ExpressionTreeRewriter<C> treeRewriter) { + return rewriteExpression(node, context, treeRewriter); + } + public Expression rewriteFunctionCall( FunctionCall node, C context, ExpressionTreeRewriter<C> treeRewriter) { return rewriteExpression(node, context, treeRewriter); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionTreeRewriter.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionTreeRewriter.java index 91c685d6d26..9e242159c6e 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionTreeRewriter.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/ir/ExpressionTreeRewriter.java @@ -28,6 +28,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Expression; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FieldReference; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.FunctionCall; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Identifier; +import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.InListExpression; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.InPredicate; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.IsNotNullPredicate; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.IsNullPredicate; @@ -451,13 +452,10 @@ public final class ExpressionTreeRewriter<C> { } Expression value = rewrite(node.getValue(), context.get()); - // List<Expression> values = node.getValueList().stream() - // .map(entry -> rewrite(entry, context.get())) - // .collect(toImmutableList()); + Expression list = rewrite(node.getValueList(), context.get()); - if (node.getValue() != value - || !sameElements(Optional.of(value), Optional.of(node.getValue()))) { - return new InPredicate(value, value); + if (node.getValue() != value || node.getValueList() != list) { + return new InPredicate(value, list); } return node; @@ -477,6 +475,25 @@ public final class ExpressionTreeRewriter<C> { // return node; // } + @Override + protected Expression visitInListExpression(InListExpression node, Context<C> context) { + if (!context.isDefaultRewrite()) { + Expression result = + rewriter.rewriteInListExpression(node, context.get(), ExpressionTreeRewriter.this); + if (result != null) { + return result; + } + } + + List<Expression> values = rewrite(node.getValues(), context); + + if (!sameElements(node.getValues(), values)) { + return new InListExpression(values); + } + + return node; + } + @Override public Expression visitCast(Cast node, Context<C> context) { if (!context.isDefaultRewrite()) {