diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java index 4457055bd3ee..bdbe468bb1ba 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBMultiIDsWithAttributesTableIT.java @@ -395,12 +395,12 @@ public void subQueryTest1() { String[] expectedHeader = new String[] {"time", "level", "device", "add_num"}; String[] retArray = new String[] { - "1970-01-01T00:00:00.100Z,l5,d1,9.0,", - "1971-01-01T00:00:01.000Z,l4,d1,6.0,", - "1971-01-01T00:00:10.000Z,l5,d1,8.0,", - "1971-04-26T18:01:40.000Z,l4,d1,14.0,", - "1971-08-20T11:33:20.000Z,l5,d1,16.0,", - "1970-01-01T00:00:00.080Z,l4,d2,10.0,", + "1970-01-01T00:00:00.100Z,l5,d1,9,", + "1971-01-01T00:00:01.000Z,l4,d1,6,", + "1971-01-01T00:00:10.000Z,l5,d1,8,", + "1971-04-26T18:01:40.000Z,l4,d1,14,", + "1971-08-20T11:33:20.000Z,l5,d1,16,", + "1970-01-01T00:00:00.080Z,l4,d2,10,", }; expectedHeader = new String[] {"time", "level", "device", "add_num"}; diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryTableIT.java index 48077696c5b1..48fbd7096aeb 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryTableIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBNestedQueryTableIT.java @@ -151,7 +151,7 @@ public void testRawDataQueryWithConstants() { for (int i = 1; i <= ITERATION_TIMES; i++) { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); - Assert.assertEquals(i + 1.0D, rs.getDouble(2), 0.01); + Assert.assertEquals(i + 1, rs.getInt(2), 0.01); } Assert.assertFalse(rs.next()); } @@ -161,7 +161,7 @@ public void testRawDataQueryWithConstants() { for (int i = 1; i <= ITERATION_TIMES; i++) { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); - Assert.assertEquals(i + 1.0D, rs.getDouble(2), 0.01); + Assert.assertEquals(i + 1, rs.getInt(2), 0.01); } Assert.assertFalse(rs.next()); } @@ -182,8 +182,8 @@ public void testDuplicatedRawDataQueryWithConstants() { for (int i = 1; i <= ITERATION_TIMES; i++) { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); - Assert.assertEquals(i + 1.0D, rs.getDouble(2), 0.01); - Assert.assertEquals(i + 1.0D, rs.getDouble(3), 0.01); + Assert.assertEquals(i + 1, rs.getInt(2), 0.01); + Assert.assertEquals(i + 1, rs.getInt(3), 0.01); } Assert.assertFalse(rs.next()); } @@ -206,10 +206,10 @@ public void testCommutativeLaws() { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); Assert.assertEquals(i, rs.getInt(2)); - Assert.assertEquals(i + 1.0D, rs.getDouble(3), 0.01); - Assert.assertEquals(i + 1.0D, rs.getDouble(4), 0.01); - Assert.assertEquals(i * 2.0D, rs.getDouble(5), 0.01); - Assert.assertEquals(i * 2.0D, rs.getDouble(6), 0.01); + Assert.assertEquals(i + 1, rs.getInt(3), 0.01); + Assert.assertEquals(i + 1, rs.getInt(4), 0.01); + Assert.assertEquals(i * 2, rs.getInt(5), 0.01); + Assert.assertEquals(i * 2, rs.getInt(6), 0.01); } Assert.assertFalse(rs.next()); } @@ -232,12 +232,12 @@ public void testAssociativeLaws() { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); Assert.assertEquals(i, rs.getInt(2)); - Assert.assertEquals(i + 3.0D, rs.getDouble(3), 0.01); - Assert.assertEquals(i + 3.0D, rs.getDouble(4), 0.01); - Assert.assertEquals(i + 3.0D, rs.getDouble(5), 0.01); - Assert.assertEquals(i * 6.0D, rs.getDouble(6), 0.01); - Assert.assertEquals(i * 6.0D, rs.getDouble(7), 0.01); - Assert.assertEquals(i * 6.0D, rs.getDouble(8), 0.01); + Assert.assertEquals(i + 3, rs.getInt(3), 0.01); + Assert.assertEquals(i + 3, rs.getInt(4), 0.01); + Assert.assertEquals(i + 3, rs.getInt(5), 0.01); + Assert.assertEquals(i * 6, rs.getInt(6), 0.01); + Assert.assertEquals(i * 6, rs.getInt(7), 0.01); + Assert.assertEquals(i * 6, rs.getInt(8), 0.01); } Assert.assertFalse(rs.next()); } @@ -260,10 +260,10 @@ public void testDistributiveLaw() { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); Assert.assertEquals(i, rs.getInt(2)); - Assert.assertEquals(2 * i + 2.0D, rs.getDouble(3), 0.01); - Assert.assertEquals(2 * i + 2.0D, rs.getDouble(4), 0.01); - Assert.assertEquals(i / 2.0D + 0.5D, rs.getDouble(5), 0.01); - Assert.assertEquals(i / 2.0D + 0.5D, rs.getDouble(6), 0.01); + Assert.assertEquals(2 * i + 2, rs.getInt(3), 0.01); + Assert.assertEquals(2 * i + 2, rs.getInt(4), 0.01); + Assert.assertEquals((i + 1) / 2, rs.getInt(5), 0.01); + Assert.assertEquals(i / 2 + 1 / 2, rs.getInt(6), 0.01); } Assert.assertFalse(rs.next()); } @@ -289,9 +289,9 @@ public void testOrderOfArithmeticOperations() { for (int i = 1; i <= ITERATION_TIMES; i++) { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); - Assert.assertEquals(2 * i + 2.0D, rs.getDouble(2), 0.01); - Assert.assertEquals(2 * i + 3.0D, rs.getDouble(3), 0.01); - Assert.assertEquals(3 * i + 3.0D, rs.getDouble(4), 0.01); + Assert.assertEquals(2 * i + 2, rs.getInt(2), 0.01); + Assert.assertEquals(2 * i + 3, rs.getInt(3), 0.01); + Assert.assertEquals(3 * i + 3, rs.getInt(4), 0.01); } Assert.assertFalse(rs.next()); } @@ -302,9 +302,9 @@ public void testOrderOfArithmeticOperations() { for (int i = 1; i <= ITERATION_TIMES; i++) { Assert.assertTrue(rs.next()); Assert.assertEquals(i, rs.getLong(1)); - Assert.assertEquals(2.0D - i / 2.0D, rs.getDouble(2), 0.01); - Assert.assertEquals(1.5 - i / 2.0D, rs.getDouble(3), 0.01); - Assert.assertEquals((1.0D / 3.0D) * (1.0D - i), rs.getDouble(4), 0.01); + Assert.assertEquals(2 - i / 2, rs.getInt(2), 0.01); + Assert.assertEquals((1 - i) / 2 + 1, rs.getInt(3), 0.01); + Assert.assertEquals((1 - i) / (2 + 1), rs.getInt(4), 0.01); } Assert.assertFalse(rs.next()); } diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceTableIT.java index 3d52c616d72c..0ba23f288f5d 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceTableIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/alignbydevice/IoTDBAlignByDeviceTableIT.java @@ -314,14 +314,14 @@ public void duplicateProjectionsTest() { String[] expectedHeader = new String[] {"Time", "device_id", "_col2", "_col3", "alias"}; String[] retArray = new String[] { - "1970-01-01T00:00:00.001Z,d0,1102.0,1102.0,1102.0,", - "1970-01-01T00:00:00.002Z,d0,40001.0,40001.0,40001.0,", - "1970-01-01T00:00:00.050Z,d0,50001.0,50001.0,50001.0,", - "1970-01-01T00:00:00.100Z,d0,200.0,200.0,200.0,", - "1970-01-01T00:00:00.101Z,d0,200.0,200.0,200.0,", - "1970-01-01T00:00:00.103Z,d0,200.0,200.0,200.0,", - "1970-01-01T00:00:00.105Z,d0,200.0,200.0,200.0,", - "1970-01-01T00:00:01.000Z,d0,55556.0,55556.0,55556.0,", + "1970-01-01T00:00:00.001Z,d0,1102,1102,1102,", + "1970-01-01T00:00:00.002Z,d0,40001,40001,40001,", + "1970-01-01T00:00:00.050Z,d0,50001,50001,50001,", + "1970-01-01T00:00:00.100Z,d0,200,200,200,", + "1970-01-01T00:00:00.101Z,d0,200,200,200,", + "1970-01-01T00:00:00.103Z,d0,200,200,200,", + "1970-01-01T00:00:00.105Z,d0,200,200,200,", + "1970-01-01T00:00:01.000Z,d0,55556,55556,55556,", }; tableResultSetEqualTest( "select Time, device_id, s1+1, s1+1, s1+1 as alias from vehicle where (((\"time\" > 10) AND (\"s1\" > 190)) OR (\"s2\" > 190.0) OR ((\"time\" < 4) AND (\"s1\" > 100))) order by device_id, time", diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/aligned/IoTDBPredicatePushDownTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/aligned/IoTDBPredicatePushDownTableIT.java index 33baa557d435..438f82d69526 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/aligned/IoTDBPredicatePushDownTableIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/aligned/IoTDBPredicatePushDownTableIT.java @@ -31,7 +31,7 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; -import static org.apache.iotdb.relational.it.query.old.aligned.TableUtils.tableResultSetEqualTest; +import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest; @RunWith(IoTDBTestRunner.class) @Category({TableLocalStandaloneIT.class, TableClusterIT.class}) @@ -62,16 +62,16 @@ public void testAlignedRawDataAlignByTime1() { String[] expectedHeader1 = new String[] {"Time", "s2", "s3"}; String[] retArray1 = new String[] { - "10,10,10,", - "11,11,11,", - "12,12,12,", - "14,14,14,", - "15,15,15,", - "16,16,16,", - "17,17,17,", - "18,18,18,", - "19,19,19,", - "20,20,20," + "1970-01-01T00:00:00.010Z,10,10,", + "1970-01-01T00:00:00.011Z,11,11,", + "1970-01-01T00:00:00.012Z,12,12,", + "1970-01-01T00:00:00.014Z,14,14,", + "1970-01-01T00:00:00.015Z,15,15,", + "1970-01-01T00:00:00.016Z,16,16,", + "1970-01-01T00:00:00.017Z,17,17,", + "1970-01-01T00:00:00.018Z,18,18,", + "1970-01-01T00:00:00.019Z,19,19,", + "1970-01-01T00:00:00.020Z,20,20," }; tableResultSetEqualTest( "select Time,s2, s3 from table0 where device='d1' and s2 - 1 >= 9 and s2 < 30", @@ -82,8 +82,16 @@ public void testAlignedRawDataAlignByTime1() { String[] expectedHeader2 = new String[] {"Time", "s3"}; String[] retArray2 = new String[] { - "10,10,", "11,11,", "12,12,", "14,14,", "15,15,", "16,16,", "17,17,", "18,18,", "19,19,", - "20,20," + "1970-01-01T00:00:00.010Z,10,", + "1970-01-01T00:00:00.011Z,11,", + "1970-01-01T00:00:00.012Z,12,", + "1970-01-01T00:00:00.014Z,14,", + "1970-01-01T00:00:00.015Z,15,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20," }; tableResultSetEqualTest( "select Time,s3 from table0 where device='d1' and s2 - 1 >= 9 and s2 < 30", @@ -94,8 +102,16 @@ public void testAlignedRawDataAlignByTime1() { String[] expectedHeader3 = new String[] {"Time", "s2"}; String[] retArray3 = new String[] { - "10,10,", "11,11,", "12,12,", "14,14,", "15,15,", "16,16,", "17,17,", "18,18,", "19,19,", - "20,20," + "1970-01-01T00:00:00.010Z,10,", + "1970-01-01T00:00:00.011Z,11,", + "1970-01-01T00:00:00.012Z,12,", + "1970-01-01T00:00:00.014Z,14,", + "1970-01-01T00:00:00.015Z,15,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20," }; tableResultSetEqualTest( "select Time,s2 from table0 where device='d1' and s2 - 1 >= 9 and s2 < 30", @@ -104,7 +120,8 @@ public void testAlignedRawDataAlignByTime1() { database); String[] expectedHeader4 = new String[] {"Time", "s2"}; - String[] retArray4 = new String[] {"14,14,", "15,15,"}; + String[] retArray4 = + new String[] {"1970-01-01T00:00:00.014Z,14,", "1970-01-01T00:00:00.015Z,15,"}; tableResultSetEqualTest( "select Time,s2 from table0 where device='d1' and s2 - 1 >= 9 and s2 < 30 offset 3 limit 2", expectedHeader4, @@ -118,23 +135,23 @@ public void testAlignedRawDataAlignByTime2() { String[] expectedHeader1 = new String[] {"Time", "s2", "_col2"}; String[] retArray1 = new String[] { - "3,null,30001.0,", - "13,130000,130001.0,", - "16,16,17.0,", - "17,17,18.0,", - "18,18,19.0,", - "19,19,20.0,", - "20,20,21.0,", - "21,null,22.0,", - "22,null,23.0,", - "23,null,230001.0,", - "24,null,25.0,", - "25,null,26.0,", - "26,null,27.0,", - "27,null,28.0,", - "28,null,29.0,", - "29,null,30.0,", - "30,null,31.0,", + "1970-01-01T00:00:00.003Z,null,30001,", + "1970-01-01T00:00:00.013Z,130000,130001,", + "1970-01-01T00:00:00.016Z,16,17,", + "1970-01-01T00:00:00.017Z,17,18,", + "1970-01-01T00:00:00.018Z,18,19,", + "1970-01-01T00:00:00.019Z,19,20,", + "1970-01-01T00:00:00.020Z,20,21,", + "1970-01-01T00:00:00.021Z,null,22,", + "1970-01-01T00:00:00.022Z,null,23,", + "1970-01-01T00:00:00.023Z,null,230001,", + "1970-01-01T00:00:00.024Z,null,25,", + "1970-01-01T00:00:00.025Z,null,26,", + "1970-01-01T00:00:00.026Z,null,27,", + "1970-01-01T00:00:00.027Z,null,28,", + "1970-01-01T00:00:00.028Z,null,29,", + "1970-01-01T00:00:00.029Z,null,30,", + "1970-01-01T00:00:00.030Z,null,31,", }; tableResultSetEqualTest( "select Time,s2, s3 + 1 from table0 where device='d1' and s3 + 1 > 16", @@ -145,23 +162,23 @@ public void testAlignedRawDataAlignByTime2() { String[] expectedHeader2 = new String[] {"Time", "s2"}; String[] retArray2 = new String[] { - "3,null,", - "13,130000,", - "16,16,", - "17,17,", - "18,18,", - "19,19,", - "20,20,", - "21,null,", - "22,null,", - "23,null,", - "24,null,", - "25,null,", - "26,null,", - "27,null,", - "28,null,", - "29,null,", - "30,null,", + "1970-01-01T00:00:00.003Z,null,", + "1970-01-01T00:00:00.013Z,130000,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20,", + "1970-01-01T00:00:00.021Z,null,", + "1970-01-01T00:00:00.022Z,null,", + "1970-01-01T00:00:00.023Z,null,", + "1970-01-01T00:00:00.024Z,null,", + "1970-01-01T00:00:00.025Z,null,", + "1970-01-01T00:00:00.026Z,null,", + "1970-01-01T00:00:00.027Z,null,", + "1970-01-01T00:00:00.028Z,null,", + "1970-01-01T00:00:00.029Z,null,", + "1970-01-01T00:00:00.030Z,null,", }; tableResultSetEqualTest( "select Time,s2 from table0 where device='d1' and s3 + 1 > 16", @@ -172,23 +189,23 @@ public void testAlignedRawDataAlignByTime2() { String[] expectedHeader3 = new String[] {"Time", "s3"}; String[] retArray3 = new String[] { - "3,30000,", - "13,130000,", - "16,16,", - "17,17,", - "18,18,", - "19,19,", - "20,20,", - "21,21,", - "22,22,", - "23,230000,", - "24,24,", - "25,25,", - "26,26,", - "27,27,", - "28,28,", - "29,29,", - "30,30,", + "1970-01-01T00:00:00.003Z,30000,", + "1970-01-01T00:00:00.013Z,130000,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20,", + "1970-01-01T00:00:00.021Z,21,", + "1970-01-01T00:00:00.022Z,22,", + "1970-01-01T00:00:00.023Z,230000,", + "1970-01-01T00:00:00.024Z,24,", + "1970-01-01T00:00:00.025Z,25,", + "1970-01-01T00:00:00.026Z,26,", + "1970-01-01T00:00:00.027Z,27,", + "1970-01-01T00:00:00.028Z,28,", + "1970-01-01T00:00:00.029Z,29,", + "1970-01-01T00:00:00.030Z,30,", }; tableResultSetEqualTest( "select Time,s3 from table0 where device='d1' and s3 + 1 > 16", @@ -197,7 +214,12 @@ public void testAlignedRawDataAlignByTime2() { database); String[] expectedHeader4 = new String[] {"Time", "s3"}; - String[] retArray4 = new String[] {"3,30000,", "13,130000,", "16,16,"}; + String[] retArray4 = + new String[] { + "1970-01-01T00:00:00.003Z,30000,", + "1970-01-01T00:00:00.013Z,130000,", + "1970-01-01T00:00:00.016Z,16," + }; tableResultSetEqualTest( "select Time,s3 from table0 where device='d1' and s3 + 1 > 16 limit 3", expectedHeader4, @@ -210,17 +232,17 @@ public void testNonAlignedRawDataAlignByTime1() { String[] expectedHeader1 = new String[] {"Time", "s2", "s3"}; String[] retArray1 = new String[] { - "10,10,10,", - "11,11,11,", - "12,12,12,", - "13,13,13,", - "14,14,14,", - "15,15,15,", - "16,16,16,", - "17,17,17,", - "18,18,18,", - "19,19,19,", - "20,20,20," + "1970-01-01T00:00:00.010Z,10,10,", + "1970-01-01T00:00:00.011Z,11,11,", + "1970-01-01T00:00:00.012Z,12,12,", + "1970-01-01T00:00:00.013Z,13,13,", + "1970-01-01T00:00:00.014Z,14,14,", + "1970-01-01T00:00:00.015Z,15,15,", + "1970-01-01T00:00:00.016Z,16,16,", + "1970-01-01T00:00:00.017Z,17,17,", + "1970-01-01T00:00:00.018Z,18,18,", + "1970-01-01T00:00:00.019Z,19,19,", + "1970-01-01T00:00:00.020Z,20,20," }; tableResultSetEqualTest( "select Time,s2, s3 from table0 where device='d2' and s2 - 1 >= 9 and s2 < 30", @@ -231,8 +253,17 @@ public void testNonAlignedRawDataAlignByTime1() { String[] expectedHeader2 = new String[] {"Time", "s3"}; String[] retArray2 = new String[] { - "10,10,", "11,11,", "12,12,", "13,13,", "14,14,", "15,15,", "16,16,", "17,17,", "18,18,", - "19,19,", "20,20," + "1970-01-01T00:00:00.010Z,10,", + "1970-01-01T00:00:00.011Z,11,", + "1970-01-01T00:00:00.012Z,12,", + "1970-01-01T00:00:00.013Z,13,", + "1970-01-01T00:00:00.014Z,14,", + "1970-01-01T00:00:00.015Z,15,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20," }; tableResultSetEqualTest( "select Time,s3 from table0 where device='d2' and s2 - 1 >= 9 and s2 < 30", @@ -243,8 +274,17 @@ public void testNonAlignedRawDataAlignByTime1() { String[] expectedHeader3 = new String[] {"Time", "s2"}; String[] retArray3 = new String[] { - "10,10,", "11,11,", "12,12,", "13,13,", "14,14,", "15,15,", "16,16,", "17,17,", "18,18,", - "19,19,", "20,20," + "1970-01-01T00:00:00.010Z,10,", + "1970-01-01T00:00:00.011Z,11,", + "1970-01-01T00:00:00.012Z,12,", + "1970-01-01T00:00:00.013Z,13,", + "1970-01-01T00:00:00.014Z,14,", + "1970-01-01T00:00:00.015Z,15,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20," }; tableResultSetEqualTest( "select Time,s2 from table0 where device='d2' and s2 - 1 >= 9 and s2 < 30", @@ -253,7 +293,12 @@ public void testNonAlignedRawDataAlignByTime1() { database); String[] expectedHeader4 = new String[] {"Time", "s2"}; - String[] retArray4 = new String[] {"12,12,", "13,13,", "14,14,"}; + String[] retArray4 = + new String[] { + "1970-01-01T00:00:00.012Z,12,", + "1970-01-01T00:00:00.013Z,13,", + "1970-01-01T00:00:00.014Z,14," + }; tableResultSetEqualTest( "select Time,s2 from table0 where device='d2' and s2 - 1 >= 9 and s2 < 30 offset 2 limit 3", expectedHeader4, @@ -266,21 +311,21 @@ public void testNonAlignedRawDataAlignByTime2() { String[] expectedHeader1 = new String[] {"Time", "s2", "s3"}; String[] retArray1 = new String[] { - "16,16,16,", - "17,17,17,", - "18,18,18,", - "19,19,19,", - "20,20,20,", - "21,null,21,", - "22,null,22,", - "23,null,23,", - "24,null,24,", - "25,null,25,", - "26,null,26,", - "27,null,27,", - "28,null,28,", - "29,null,29,", - "30,null,30,", + "1970-01-01T00:00:00.016Z,16,16,", + "1970-01-01T00:00:00.017Z,17,17,", + "1970-01-01T00:00:00.018Z,18,18,", + "1970-01-01T00:00:00.019Z,19,19,", + "1970-01-01T00:00:00.020Z,20,20,", + "1970-01-01T00:00:00.021Z,null,21,", + "1970-01-01T00:00:00.022Z,null,22,", + "1970-01-01T00:00:00.023Z,null,23,", + "1970-01-01T00:00:00.024Z,null,24,", + "1970-01-01T00:00:00.025Z,null,25,", + "1970-01-01T00:00:00.026Z,null,26,", + "1970-01-01T00:00:00.027Z,null,27,", + "1970-01-01T00:00:00.028Z,null,28,", + "1970-01-01T00:00:00.029Z,null,29,", + "1970-01-01T00:00:00.030Z,null,30,", }; tableResultSetEqualTest( "select Time,s2, s3 from table0 where device='d2' and s3 + 1 > 16", @@ -291,21 +336,21 @@ public void testNonAlignedRawDataAlignByTime2() { String[] expectedHeader2 = new String[] {"Time", "s2"}; String[] retArray2 = new String[] { - "16,16,", - "17,17,", - "18,18,", - "19,19,", - "20,20,", - "21,null,", - "22,null,", - "23,null,", - "24,null,", - "25,null,", - "26,null,", - "27,null,", - "28,null,", - "29,null,", - "30,null,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20,", + "1970-01-01T00:00:00.021Z,null,", + "1970-01-01T00:00:00.022Z,null,", + "1970-01-01T00:00:00.023Z,null,", + "1970-01-01T00:00:00.024Z,null,", + "1970-01-01T00:00:00.025Z,null,", + "1970-01-01T00:00:00.026Z,null,", + "1970-01-01T00:00:00.027Z,null,", + "1970-01-01T00:00:00.028Z,null,", + "1970-01-01T00:00:00.029Z,null,", + "1970-01-01T00:00:00.030Z,null,", }; tableResultSetEqualTest( "select Time,s2 from table0 where device='d2' and s3 + 1 > 16", @@ -316,8 +361,21 @@ public void testNonAlignedRawDataAlignByTime2() { String[] expectedHeader3 = new String[] {"Time", "s3"}; String[] retArray3 = new String[] { - "16,16,", "17,17,", "18,18,", "19,19,", "20,20,", "21,21,", "22,22,", "23,23,", "24,24,", - "25,25,", "26,26,", "27,27,", "28,28,", "29,29,", "30,30,", + "1970-01-01T00:00:00.016Z,16,", + "1970-01-01T00:00:00.017Z,17,", + "1970-01-01T00:00:00.018Z,18,", + "1970-01-01T00:00:00.019Z,19,", + "1970-01-01T00:00:00.020Z,20,", + "1970-01-01T00:00:00.021Z,21,", + "1970-01-01T00:00:00.022Z,22,", + "1970-01-01T00:00:00.023Z,23,", + "1970-01-01T00:00:00.024Z,24,", + "1970-01-01T00:00:00.025Z,25,", + "1970-01-01T00:00:00.026Z,26,", + "1970-01-01T00:00:00.027Z,27,", + "1970-01-01T00:00:00.028Z,28,", + "1970-01-01T00:00:00.029Z,29,", + "1970-01-01T00:00:00.030Z,30,", }; tableResultSetEqualTest( "select Time,s3 from table0 where device='d2' and s3 + 1 > 16", @@ -328,7 +386,11 @@ public void testNonAlignedRawDataAlignByTime2() { String[] expectedHeader4 = new String[] {"Time", "s3"}; String[] retArray4 = new String[] { - "26,26,", "27,27,", "28,28,", "29,29,", "30,30,", + "1970-01-01T00:00:00.026Z,26,", + "1970-01-01T00:00:00.027Z,27,", + "1970-01-01T00:00:00.028Z,28,", + "1970-01-01T00:00:00.029Z,29,", + "1970-01-01T00:00:00.030Z,30,", }; tableResultSetEqualTest( "select Time,s3 from table0 where device='d2' and s3 + 1 > 16 offset 10", @@ -539,27 +601,27 @@ public void testRawDataAlignByDevice1() { String[] expectedHeader = new String[] {"Time", "Device", "s2", "s3"}; String[] retArray = new String[] { - "10,d2,10,10,", - "11,d2,11,11,", - "12,d2,12,12,", - "13,d2,13,13,", - "14,d2,14,14,", - "15,d2,15,15,", - "16,d2,16,16,", - "17,d2,17,17,", - "18,d2,18,18,", - "19,d2,19,19,", - "20,d2,20,20,", - "10,d1,10,10,", - "11,d1,11,11,", - "12,d1,12,12,", - "14,d1,14,14,", - "15,d1,15,15,", - "16,d1,16,16,", - "17,d1,17,17,", - "18,d1,18,18,", - "19,d1,19,19,", - "20,d1,20,20," + "1970-01-01T00:00:00.010Z,d2,10,10,", + "1970-01-01T00:00:00.011Z,d2,11,11,", + "1970-01-01T00:00:00.012Z,d2,12,12,", + "1970-01-01T00:00:00.013Z,d2,13,13,", + "1970-01-01T00:00:00.014Z,d2,14,14,", + "1970-01-01T00:00:00.015Z,d2,15,15,", + "1970-01-01T00:00:00.016Z,d2,16,16,", + "1970-01-01T00:00:00.017Z,d2,17,17,", + "1970-01-01T00:00:00.018Z,d2,18,18,", + "1970-01-01T00:00:00.019Z,d2,19,19,", + "1970-01-01T00:00:00.020Z,d2,20,20,", + "1970-01-01T00:00:00.010Z,d1,10,10,", + "1970-01-01T00:00:00.011Z,d1,11,11,", + "1970-01-01T00:00:00.012Z,d1,12,12,", + "1970-01-01T00:00:00.014Z,d1,14,14,", + "1970-01-01T00:00:00.015Z,d1,15,15,", + "1970-01-01T00:00:00.016Z,d1,16,16,", + "1970-01-01T00:00:00.017Z,d1,17,17,", + "1970-01-01T00:00:00.018Z,d1,18,18,", + "1970-01-01T00:00:00.019Z,d1,19,19,", + "1970-01-01T00:00:00.020Z,d1,20,20,", }; tableResultSetEqualTest( "select Time, Device,s2, s3 from table0 where s2 - 1 >= 9 and s2 < 30 order by device desc", @@ -573,38 +635,38 @@ public void testRawDataAlignByDevice2() { String[] expectedHeader = new String[] {"Time", "Device", "s2", "_col3"}; String[] retArray = new String[] { - "3,d1,null,30001.0,", - "13,d1,130000,130001.0,", - "16,d1,16,17.0,", - "17,d1,17,18.0,", - "18,d1,18,19.0,", - "19,d1,19,20.0,", - "20,d1,20,21.0,", - "21,d1,null,22.0,", - "22,d1,null,23.0,", - "23,d1,null,230001.0,", - "24,d1,null,25.0,", - "25,d1,null,26.0,", - "26,d1,null,27.0,", - "27,d1,null,28.0,", - "28,d1,null,29.0,", - "29,d1,null,30.0,", - "30,d1,null,31.0,", - "16,d2,16,17.0,", - "17,d2,17,18.0,", - "18,d2,18,19.0,", - "19,d2,19,20.0,", - "20,d2,20,21.0,", - "21,d2,null,22.0,", - "22,d2,null,23.0,", - "23,d2,null,24.0,", - "24,d2,null,25.0,", - "25,d2,null,26.0,", - "26,d2,null,27.0,", - "27,d2,null,28.0,", - "28,d2,null,29.0,", - "29,d2,null,30.0,", - "30,d2,null,31.0,", + "1970-01-01T00:00:00.003Z,d1,null,30001,", + "1970-01-01T00:00:00.013Z,d1,130000,130001,", + "1970-01-01T00:00:00.016Z,d1,16,17,", + "1970-01-01T00:00:00.017Z,d1,17,18,", + "1970-01-01T00:00:00.018Z,d1,18,19,", + "1970-01-01T00:00:00.019Z,d1,19,20,", + "1970-01-01T00:00:00.020Z,d1,20,21,", + "1970-01-01T00:00:00.021Z,d1,null,22,", + "1970-01-01T00:00:00.022Z,d1,null,23,", + "1970-01-01T00:00:00.023Z,d1,null,230001,", + "1970-01-01T00:00:00.024Z,d1,null,25,", + "1970-01-01T00:00:00.025Z,d1,null,26,", + "1970-01-01T00:00:00.026Z,d1,null,27,", + "1970-01-01T00:00:00.027Z,d1,null,28,", + "1970-01-01T00:00:00.028Z,d1,null,29,", + "1970-01-01T00:00:00.029Z,d1,null,30,", + "1970-01-01T00:00:00.030Z,d1,null,31,", + "1970-01-01T00:00:00.016Z,d2,16,17,", + "1970-01-01T00:00:00.017Z,d2,17,18,", + "1970-01-01T00:00:00.018Z,d2,18,19,", + "1970-01-01T00:00:00.019Z,d2,19,20,", + "1970-01-01T00:00:00.020Z,d2,20,21,", + "1970-01-01T00:00:00.021Z,d2,null,22,", + "1970-01-01T00:00:00.022Z,d2,null,23,", + "1970-01-01T00:00:00.023Z,d2,null,24,", + "1970-01-01T00:00:00.024Z,d2,null,25,", + "1970-01-01T00:00:00.025Z,d2,null,26,", + "1970-01-01T00:00:00.026Z,d2,null,27,", + "1970-01-01T00:00:00.027Z,d2,null,28,", + "1970-01-01T00:00:00.028Z,d2,null,29,", + "1970-01-01T00:00:00.029Z,d2,null,30,", + "1970-01-01T00:00:00.030Z,d2,null,31,", }; tableResultSetEqualTest( "select Time,Device,s2, s3 + 1 from table0 where s3 + 1 > 16 order by device", diff --git a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java index 91ff9309c826..d3cc7b19f36f 100644 --- a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java +++ b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/orderBy/IoTDBOrderByTableIT.java @@ -277,7 +277,7 @@ public void orderByTest15() { while (resultSet.next()) { long actualTime = resultSet.getLong(1); - double actualNum = resultSet.getDouble(2); + double actualNum = resultSet.getLong(2); double actualFloat = resultSet.getDouble(3); assertEquals(Long.parseLong(RES[ans[i]][0]), actualTime); @@ -351,7 +351,7 @@ public void orderByTest14() { while (resultSet.next()) { long actualTime = resultSet.getLong(1); - double actualNum = resultSet.getDouble(2); + double actualNum = resultSet.getLong(2); assertEquals(Long.parseLong(RES[ans[i]][0]), actualTime); assertEquals( @@ -744,7 +744,7 @@ public void alignByDeviceOrderByTest1() { while (resultSet.next()) { long actualTime = resultSet.getLong(1); String actualDevice = resultSet.getString(2); - double actualNum = resultSet.getDouble(3); + double actualNum = resultSet.getLong(3); assertEquals(device, actualDevice); assertEquals(Long.parseLong(RES[ans[i]][0]), actualTime); diff --git a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/relational/ColumnTransformerBuilder.java b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/relational/ColumnTransformerBuilder.java index 18090b3f4636..82179fff7465 100644 --- a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/relational/ColumnTransformerBuilder.java +++ b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/relational/ColumnTransformerBuilder.java @@ -23,6 +23,11 @@ import org.apache.iotdb.db.queryengine.common.SessionInfo; import org.apache.iotdb.db.queryengine.plan.analyze.TypeProvider; import org.apache.iotdb.db.queryengine.plan.planner.plan.parameter.InputLocation; +import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.AdditionResolver; +import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.DivisionResolver; +import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.ModulusResolver; +import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.MultiplicationResolver; +import org.apache.iotdb.db.queryengine.plan.relational.function.arithmetic.SubtractionResolver; import org.apache.iotdb.db.queryengine.plan.relational.metadata.Metadata; import org.apache.iotdb.db.queryengine.plan.relational.planner.Symbol; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ArithmeticBinaryExpression; @@ -59,6 +64,7 @@ import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.StringLiteral; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.SymbolReference; import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Trim; +import org.apache.iotdb.db.queryengine.plan.relational.type.InternalTypeManager; import org.apache.iotdb.db.queryengine.plan.relational.type.TypeNotFoundException; import org.apache.iotdb.db.queryengine.transformation.dag.column.ColumnTransformer; import org.apache.iotdb.db.queryengine.transformation.dag.column.binary.ArithmeticColumnTransformerApi; @@ -156,6 +162,7 @@ import java.time.ZoneId; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -191,14 +198,39 @@ protected ColumnTransformer visitArithmeticBinary( ArithmeticBinaryExpression node, Context context) { if (!context.cache.containsKey(node)) { if (context.hasSeen.containsKey(node)) { + ColumnTransformer left = process(node.getLeft(), context); + ColumnTransformer right = process(node.getRight(), context); + List types = Arrays.asList(left.getType(), right.getType()); + Type type; + switch (node.getOperator()) { + case ADD: + type = AdditionResolver.checkConditions(types).get(); + break; + case SUBTRACT: + type = SubtractionResolver.checkConditions(types).get(); + break; + case MULTIPLY: + type = MultiplicationResolver.checkConditions(types).get(); + break; + case DIVIDE: + type = DivisionResolver.checkConditions(types).get(); + break; + case MODULUS: + type = ModulusResolver.checkConditions(types).get(); + break; + default: + throw new UnsupportedOperationException( + String.format(UNSUPPORTED_EXPRESSION, node.getOperator())); + } + TSDataType tsDataType = InternalTypeManager.getTSDataType(type); IdentityColumnTransformer identity = new IdentityColumnTransformer( - DOUBLE, context.originSize + context.commonTransformerList.size()); + type, context.originSize + context.commonTransformerList.size()); ColumnTransformer columnTransformer = context.hasSeen.get(node); columnTransformer.addReferenceCount(); context.commonTransformerList.add(columnTransformer); context.leafList.add(identity); - context.inputDataTypes.add(TSDataType.DOUBLE); + context.inputDataTypes.add(tsDataType); context.cache.put(node, identity); } else { ZoneId zoneId = context.sessionInfo.getZoneId();