Skip to content

Commit 328b3d7

Browse files
committed
Refactor arithmetic operation tests to use integer types instead of doubles
1 parent a026201 commit 328b3d7

File tree

18 files changed

+196
-306
lines changed

18 files changed

+196
-306
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,13 @@ public void testMismatchedDataTypes() {
203203
"The output type of the expression in WHERE clause should be BOOLEAN, actual data type: DOUBLE.");
204204
assertTestFail(
205205
"select count(s1) from root.sg1.d1 group by ([0, 40), 5ms) having count(s1) + 1;",
206-
"The output type of the expression in HAVING clause should be BOOLEAN, actual data type: DOUBLE.");
206+
"The output type of the expression in HAVING clause should be BOOLEAN, actual data type: INT64.");
207207
assertTestFail(
208208
"select s1 from root.sg1.d1 where s1 align by device;",
209209
"The output type of the expression in WHERE clause should be BOOLEAN, actual data type: DOUBLE.");
210210
assertTestFail(
211211
"select count(s1) from root.sg1.d1 group by ([0, 40), 5ms) having count(s1) + 1 align by device;",
212-
"The output type of the expression in HAVING clause should be BOOLEAN, actual data type: DOUBLE.");
212+
"The output type of the expression in HAVING clause should be BOOLEAN, actual data type: INT64.");
213213
}
214214

215215
@Test

integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBNestedQueryIT.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,10 @@ public void testDistributiveLaw() {
496496
Assert.assertTrue(rs.next());
497497
Assert.assertEquals(i, rs.getLong(1));
498498
Assert.assertEquals(i, rs.getInt(2));
499-
Assert.assertEquals(2 * i + 2.0D, rs.getDouble(3), 0.01);
500-
Assert.assertEquals(2 * i + 2.0D, rs.getDouble(4), 0.01);
501-
Assert.assertEquals(i / 2.0D + 0.5D, rs.getDouble(5), 0.01);
502-
Assert.assertEquals((i / 2) + 1 / 2, rs.getDouble(6), 0.01);
499+
Assert.assertEquals((i + 1) * 2, rs.getLong(3));
500+
Assert.assertEquals(i * 2 + 1 * 2, rs.getLong(4));
501+
Assert.assertEquals((i + 1) / 2, rs.getLong(5));
502+
Assert.assertEquals(i / 2 + 1 / 2, rs.getLong(6));
503503
}
504504
Assert.assertFalse(rs.next());
505505
}
@@ -524,9 +524,9 @@ public void testOrderOfArithmeticOperations() {
524524
for (int i = 1; i <= ITERATION_TIMES; i++) {
525525
Assert.assertTrue(rs.next());
526526
Assert.assertEquals(i, rs.getLong(1));
527-
Assert.assertEquals(2 * i + 2.0D, rs.getDouble(2), 0.01);
528-
Assert.assertEquals(2 * i + 3.0D, rs.getDouble(3), 0.01);
529-
Assert.assertEquals(3 * i + 3.0D, rs.getDouble(4), 0.01);
527+
Assert.assertEquals(1 + i * 2 + 1, rs.getLong(2));
528+
Assert.assertEquals((1 + i) * 2 + 1, rs.getLong(3));
529+
Assert.assertEquals((1 + i) * (2 + 1), rs.getLong(4));
530530
}
531531
Assert.assertFalse(rs.next());
532532
}
@@ -536,9 +536,9 @@ public void testOrderOfArithmeticOperations() {
536536
for (int i = 1; i <= ITERATION_TIMES; i++) {
537537
Assert.assertTrue(rs.next());
538538
Assert.assertEquals(i, rs.getLong(1));
539-
Assert.assertEquals(1.0D - i / 2 + 1, rs.getDouble(2), 0.01);
540-
Assert.assertEquals(1.5 - i / 2.0D, rs.getDouble(3), 0.01);
541-
Assert.assertEquals((1.0D / 3.0D) * (1.0D - i), rs.getDouble(4), 0.01);
539+
Assert.assertEquals(1 - i / 2 + 1, rs.getLong(2));
540+
Assert.assertEquals((1 - i) / 2 + 1, rs.getLong(3));
541+
Assert.assertEquals((1 - i) / (2 + 1), rs.getLong(4));
542542
}
543543
Assert.assertFalse(rs.next());
544544
}

integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/maxby/IoTDBMaxByIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public void testMaxByWithExpression() {
301301
"max_by(root.db.d1.x5, -cos(sin(root.db.d1.y2 / 10)))",
302302
"max_by(REPLACE(root.db.d1.x6, '3', '4'), -cos(sin(root.db.d1.y2 / 10)))",
303303
};
304-
String[] retArray = new String[] {"0.0,1.3333333333333333,2.0,2.0,false,2,"};
304+
String[] retArray = new String[] {"0,1.3333333333333333,2.0,2.0,false,2,"};
305305
String y = "-cos(sin(y2 / 10))";
306306
resultSetEqualTest(
307307
String.format(
@@ -331,8 +331,8 @@ public void testMaxByWithAlignByDevice() {
331331
};
332332
String[] retArray =
333333
new String[] {
334-
"root.db.d1,0.0,1.3333333333333333,2.0,2.0,false,2,",
335-
"root.db.d2,0.0,1.3333333333333333,2.0,2.0,false,2,"
334+
"root.db.d1,0,1.3333333333333333,2.0,2.0,false,2,",
335+
"root.db.d2,0,1.3333333333333333,2.0,2.0,false,2,"
336336
};
337337
String y = "-cos(sin(y2 / 10))";
338338
resultSetEqualTest(

integration-test/src/test/java/org/apache/iotdb/db/it/aggregation/minby/IoTDBMinByIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ public void testMaxByWithExpression() {
300300
"min_by(root.db.d1.x5, -cos(sin(root.db.d1.y2 / 10)))",
301301
"min_by(REPLACE(root.db.d1.x6, '3', '4'), -cos(sin(root.db.d1.y2 / 10)))",
302302
};
303-
String[] retArray = new String[] {"0.0,1.3333333333333333,2.0,2.0,false,2,"};
303+
String[] retArray = new String[] {"0,1.3333333333333333,2.0,2.0,false,2,"};
304304
String y = "-cos(sin(y2 / 10))";
305305
resultSetEqualTest(
306306
String.format(
@@ -330,8 +330,8 @@ public void testMaxByWithAlignByDevice() {
330330
};
331331
String[] retArray =
332332
new String[] {
333-
"root.db.d1,0.0,1.3333333333333333,2.0,2.0,false,2,",
334-
"root.db.d2,0.0,1.3333333333333333,2.0,2.0,false,2,"
333+
"root.db.d1,0,1.3333333333333333,2.0,2.0,false,2,",
334+
"root.db.d2,0,1.3333333333333333,2.0,2.0,false,2,"
335335
};
336336
String y = "-cos(sin(y2 / 10))";
337337
resultSetEqualTest(

integration-test/src/test/java/org/apache/iotdb/db/it/alignbydevice/IoTDBAlignByDeviceWithTemplateAggregationIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,19 +217,19 @@ public void filterTest() {
217217
new String[] {"Device,max_time(s1),count(s1),last_value(s2),count(s1) + last_value(s3)"};
218218
retArray =
219219
new String[] {
220-
"root.sg1.d2,1314000000001,4,false,1319.0,",
221-
"root.sg1.d3,1314000000002,2,false,1318.0,",
222-
"root.sg1.d4,5,1,false,5556.0,",
220+
"root.sg1.d2,1314000000001,4,false,1319,",
221+
"root.sg1.d3,1314000000002,2,false,1318,",
222+
"root.sg1.d4,5,1,false,5556,",
223223
};
224224
resultSetEqualTest(
225225
"SELECT max_time(s1), count(s1), last_value(s2), count(s1)+last_value(s3) FROM root.sg1.** where s3+1=1316 or s2=false having avg(s1)+sum(s3)>5 align by device;",
226226
expectedHeader,
227227
retArray);
228228
retArray =
229229
new String[] {
230-
"root.sg2.d2,1314000000001,4,false,1319.0,",
231-
"root.sg2.d3,1314000000002,2,false,1318.0,",
232-
"root.sg2.d4,5,1,false,5556.0,",
230+
"root.sg2.d2,1314000000001,4,false,1319,",
231+
"root.sg2.d3,1314000000002,2,false,1318,",
232+
"root.sg2.d4,5,1,false,5556,",
233233
};
234234
resultSetEqualTest(
235235
"SELECT max_time(s1), count(s1), last_value(s2), count(s1)+last_value(s3) FROM root.sg2.** where s3+1=1316 or s2=false having avg(s1)+sum(s3)>5 align by device;",
@@ -650,15 +650,15 @@ public void wildCardTest() {
650650
expectedHeader = new String[] {"Device,count(s3) + 1,count(s1) + 1,count(s2) + 1"};
651651
retArray =
652652
new String[] {
653-
"root.sg1.d2,5.0,5.0,5.0,",
653+
"root.sg1.d2,5,5,5,",
654654
};
655655
resultSetEqualTest(
656656
"SELECT count(*)+1 FROM root.sg1.** where s2=false having count(s3+s1) > 2 align by device;",
657657
expectedHeader,
658658
retArray);
659659
retArray =
660660
new String[] {
661-
"root.sg2.d2,5.0,5.0,5.0,",
661+
"root.sg2.d2,5,5,5,",
662662
};
663663
resultSetEqualTest(
664664
"SELECT count(*)+1 FROM root.sg2.** where s2=false having count(s3+s1) > 2 align by device;",

integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBPredicatePushDownIT.java

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,23 @@ public void testAlignedRawDataAlignByTime2() {
114114
String expectedHeader1 = "Time,root.sg1.d1.s2,root.sg1.d1.s3 + 1,";
115115
String[] retArray1 =
116116
new String[] {
117-
"3,null,30001.0,",
118-
"13,130000,130001.0,",
119-
"16,16,17.0,",
120-
"17,17,18.0,",
121-
"18,18,19.0,",
122-
"19,19,20.0,",
123-
"20,20,21.0,",
124-
"21,null,22.0,",
125-
"22,null,23.0,",
126-
"23,null,230001.0,",
127-
"24,null,25.0,",
128-
"25,null,26.0,",
129-
"26,null,27.0,",
130-
"27,null,28.0,",
131-
"28,null,29.0,",
132-
"29,null,30.0,",
133-
"30,null,31.0,",
117+
"3,null,30001,",
118+
"13,130000,130001,",
119+
"16,16,17,",
120+
"17,17,18,",
121+
"18,18,19,",
122+
"19,19,20,",
123+
"20,20,21,",
124+
"21,null,22,",
125+
"22,null,23,",
126+
"23,null,230001,",
127+
"24,null,25,",
128+
"25,null,26,",
129+
"26,null,27,",
130+
"27,null,28,",
131+
"28,null,29,",
132+
"29,null,30,",
133+
"30,null,31,",
134134
};
135135
resultSetEqualTest(
136136
"select s2, s3 + 1 from root.sg1.d1 where s3 + 1 > 16", expectedHeader1, retArray1);
@@ -536,38 +536,38 @@ public void testRawDataAlignByDevice2() {
536536
String expectedHeader = "Time,Device,s2,s3 + 1,";
537537
String[] retArray =
538538
new String[] {
539-
"3,root.sg1.d1,null,30001.0,",
540-
"13,root.sg1.d1,130000,130001.0,",
541-
"16,root.sg1.d1,16,17.0,",
542-
"17,root.sg1.d1,17,18.0,",
543-
"18,root.sg1.d1,18,19.0,",
544-
"19,root.sg1.d1,19,20.0,",
545-
"20,root.sg1.d1,20,21.0,",
546-
"21,root.sg1.d1,null,22.0,",
547-
"22,root.sg1.d1,null,23.0,",
548-
"23,root.sg1.d1,null,230001.0,",
549-
"24,root.sg1.d1,null,25.0,",
550-
"25,root.sg1.d1,null,26.0,",
551-
"26,root.sg1.d1,null,27.0,",
552-
"27,root.sg1.d1,null,28.0,",
553-
"28,root.sg1.d1,null,29.0,",
554-
"29,root.sg1.d1,null,30.0,",
555-
"30,root.sg1.d1,null,31.0,",
556-
"16,root.sg1.d2,16,17.0,",
557-
"17,root.sg1.d2,17,18.0,",
558-
"18,root.sg1.d2,18,19.0,",
559-
"19,root.sg1.d2,19,20.0,",
560-
"20,root.sg1.d2,20,21.0,",
561-
"21,root.sg1.d2,null,22.0,",
562-
"22,root.sg1.d2,null,23.0,",
563-
"23,root.sg1.d2,null,24.0,",
564-
"24,root.sg1.d2,null,25.0,",
565-
"25,root.sg1.d2,null,26.0,",
566-
"26,root.sg1.d2,null,27.0,",
567-
"27,root.sg1.d2,null,28.0,",
568-
"28,root.sg1.d2,null,29.0,",
569-
"29,root.sg1.d2,null,30.0,",
570-
"30,root.sg1.d2,null,31.0,",
539+
"3,root.sg1.d1,null,30001,",
540+
"13,root.sg1.d1,130000,130001,",
541+
"16,root.sg1.d1,16,17,",
542+
"17,root.sg1.d1,17,18,",
543+
"18,root.sg1.d1,18,19,",
544+
"19,root.sg1.d1,19,20,",
545+
"20,root.sg1.d1,20,21,",
546+
"21,root.sg1.d1,null,22,",
547+
"22,root.sg1.d1,null,23,",
548+
"23,root.sg1.d1,null,230001,",
549+
"24,root.sg1.d1,null,25,",
550+
"25,root.sg1.d1,null,26,",
551+
"26,root.sg1.d1,null,27,",
552+
"27,root.sg1.d1,null,28,",
553+
"28,root.sg1.d1,null,29,",
554+
"29,root.sg1.d1,null,30,",
555+
"30,root.sg1.d1,null,31,",
556+
"16,root.sg1.d2,16,17,",
557+
"17,root.sg1.d2,17,18,",
558+
"18,root.sg1.d2,18,19,",
559+
"19,root.sg1.d2,19,20,",
560+
"20,root.sg1.d2,20,21,",
561+
"21,root.sg1.d2,null,22,",
562+
"22,root.sg1.d2,null,23,",
563+
"23,root.sg1.d2,null,24,",
564+
"24,root.sg1.d2,null,25,",
565+
"25,root.sg1.d2,null,26,",
566+
"26,root.sg1.d2,null,27,",
567+
"27,root.sg1.d2,null,28,",
568+
"28,root.sg1.d2,null,29,",
569+
"29,root.sg1.d2,null,30,",
570+
"30,root.sg1.d2,null,31,",
571571
};
572572
resultSetEqualTest(
573573
"select s2, s3 + 1 from root.sg1.d1, root.sg1.d2 where s3 + 1 > 16 align by device",

integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBCaseWhenThenIT.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void testKind1InputTypeRestrict() {
154154
// WHEN clause must return BOOLEAN
155155
String sql = "select case when s1+1 then 20 else 22 end from root.sg.d1";
156156
String msg =
157-
"701: The expression in the WHEN clause must return BOOLEAN. expression: root.sg.d1.s1 + 1, actual data type: DOUBLE.";
157+
"701: The expression in the WHEN clause must return BOOLEAN. expression: root.sg.d1.s1 + 1, actual data type: INT64.";
158158
assertTestFail(sql, msg);
159159
}
160160

@@ -493,8 +493,8 @@ public void testKind1UseOtherOperation() {
493493
new String[] {
494494
"0,root.sg.d1,null,",
495495
"1000000,root.sg.d1,11.0,",
496-
"20000000,root.sg.d1,21.0,",
497-
"210000000,root.sg.d1,32.0,",
496+
"20000000,root.sg.d1,21,",
497+
"210000000,root.sg.d1,32,",
498498
};
499499
resultSetEqualTest(sql, expectHeader, retArray);
500500

@@ -543,10 +543,10 @@ public void testKind2UseOtherOperation() {
543543
};
544544
retArray =
545545
new String[] {
546-
"0,root.sg.d1,-1.0,",
546+
"0,root.sg.d1,-1,",
547547
"1000000,root.sg.d1,11.0,",
548-
"20000000,root.sg.d1,21.0,",
549-
"210000000,root.sg.d1,32.0,",
548+
"20000000,root.sg.d1,21,",
549+
"210000000,root.sg.d1,32,",
550550
};
551551
resultSetEqualTest(sql, expectHeader, retArray);
552552

@@ -734,7 +734,7 @@ public void testKind1MultipleTimeseries() {
734734
};
735735
String[] retArray =
736736
new String[] {
737-
"0,0.0,0.0,", "1000000,121.0,11.0,", "20000000,484.0,66.0,", "210000000,1089.0,77.0,",
737+
"0,0,0.0,", "1000000,121,11.0,", "20000000,484,66.0,", "210000000,1089,77.0,",
738738
};
739739
resultSetEqualTest(sql, expectedHeader, retArray);
740740

@@ -773,7 +773,7 @@ public void testKind2MultipleTimeseries() {
773773
};
774774
String[] retArray =
775775
new String[] {
776-
"0,0.0,44.0,", "1000000,121.0,11.0,", "20000000,484.0,66.0,", "210000000,1089.0,77.0,",
776+
"0,0,44.0,", "1000000,121,11.0,", "20000000,484,66.0,", "210000000,1089,77.0,",
777777
};
778778
resultSetEqualTest(sql, expectedHeader, retArray);
779779

integration-test/src/test/java/org/apache/iotdb/db/it/udaf/IoTDBUDAFMiscIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void mixUDAFAndUDTFTest() throws Exception {
106106

107107
@Test
108108
public void UDAFAsOperandTest() throws Exception {
109-
String[] expected = new String[] {"6.0"};
109+
String[] expected = new String[] {"6"};
110110
try (Connection connection = EnvFactory.getEnv().getConnection();
111111
Statement statement = connection.createStatement()) {
112112

integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFWindowQueryIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ public void testSizeWindowUDFWithConstants() {
735735
Statement statement = connection.createStatement()) {
736736

737737
String query =
738-
"SELECT accumulator(s1 + 1, 'access'='size', 'windowSize'='1000') FROM root.vehicle.d1";
738+
"SELECT accumulator(s1 + 1.0, 'access'='size', 'windowSize'='1000') FROM root.vehicle.d1";
739739
try (ResultSet rs = statement.executeQuery(query)) {
740740
int time = 0;
741741
int value = 500500;
@@ -750,7 +750,7 @@ public void testSizeWindowUDFWithConstants() {
750750
}
751751

752752
query =
753-
"SELECT 1 + accumulator(s1 + 1, 'access'='size', 'windowSize'='1000') FROM root.vehicle.d1";
753+
"SELECT 1 + accumulator(s1 + 1.0, 'access'='size', 'windowSize'='1000') FROM root.vehicle.d1";
754754
try (ResultSet rs = statement.executeQuery(query)) {
755755
int time = 0;
756756
double value = 500501D;
@@ -775,7 +775,7 @@ public void testTimeWindowUDFWithConstants() {
775775
Statement statement = connection.createStatement()) {
776776
String query =
777777
"SELECT accumulator("
778-
+ "s1 + 1, "
778+
+ "s1 + 1.0, "
779779
+ "'access'='time', "
780780
+ "'timeInterval'='1000', "
781781
+ "'slidingStep'='1000', "
@@ -796,7 +796,7 @@ public void testTimeWindowUDFWithConstants() {
796796

797797
query =
798798
"SELECT 1 + accumulator("
799-
+ "s1 + 1, "
799+
+ "s1 + 1.0, "
800800
+ "'access'='time', "
801801
+ "'timeInterval'='1000', "
802802
+ "'slidingStep'='1000', "

integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDTFHybridQueryIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ public void testUserDefinedBuiltInHybridAggregationQuery2() {
159159
public void testUserDefinedFunctionFillFunctionHybridQuery() {
160160
String[] retArray =
161161
new String[] {
162-
"0,0.0,1.0,3.14",
163-
"1,0.8414709848078965,2.0,3.14",
164-
"2,0.9092974268256817,3.0,2.0",
165-
"3,0.1411200080598672,4.0,3.0",
166-
"4,-0.7568024953079282,5.0,3.14",
162+
"0,0.0,1,3.14",
163+
"1,0.8414709848078965,2,3.14",
164+
"2,0.9092974268256817,3,2.0",
165+
"3,0.1411200080598672,4,3.0",
166+
"4,-0.7568024953079282,5,3.14",
167167
"7,3.14,3.14,7.0",
168168
"8,3.14,3.14,8.0",
169169
"9,3.14,3.14,9.0"

0 commit comments

Comments
 (0)