Skip to content

Commit

Permalink
Keep all null rows in table model
Browse files Browse the repository at this point in the history
  • Loading branch information
JackieTien97 authored Sep 13, 2024
1 parent f99509b commit f227d9a
Show file tree
Hide file tree
Showing 33 changed files with 665 additions and 231 deletions.
Binary file removed data.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ public void testInsertAlignedNullableValues() throws SQLException {
assertTrue(resultSet.getBoolean(1));
assertTrue(resultSet.next());
assertTrue(resultSet.getBoolean(1));
assertTrue(resultSet.next());
resultSet.getBoolean(1);
assertTrue(resultSet.wasNull());
assertFalse(resultSet.next());
}

Expand Down Expand Up @@ -174,6 +177,9 @@ public void testUpdatingAlignedValues() throws SQLException {
assertTrue(resultSet.getBoolean(2));
assertTrue(resultSet.next());
assertTrue(resultSet.getBoolean(2));
assertTrue(resultSet.next());
resultSet.getBoolean(2);
assertTrue(resultSet.wasNull());
assertFalse(resultSet.next());
}

Expand Down Expand Up @@ -204,6 +210,9 @@ public void testUpdatingAlignedValues() throws SQLException {
assertTrue(resultSet.getBoolean(2));
assertTrue(resultSet.next());
assertTrue(resultSet.getBoolean(2));
assertTrue(resultSet.next());
resultSet.getBoolean(2);
assertTrue(resultSet.wasNull());
assertFalse(resultSet.next());
}

Expand Down Expand Up @@ -393,19 +402,29 @@ public void testInsertAlignedWithEmptyPage() throws SQLException {
int rowCount = 0;
try (ResultSet resultSet = statement.executeQuery("select time, s3 from dev10")) {
while (resultSet.next()) {
assertEquals(99, resultSet.getInt(2));
int v = resultSet.getInt(2);
if (rowCount == 99) {
assertEquals(99, v);
} else {
assertTrue(resultSet.wasNull());
}
rowCount++;
}
assertEquals(1, rowCount);
assertEquals(100, rowCount);
}

try (ResultSet resultSet = statement.executeQuery("select time, s2 from dev10")) {
rowCount = 0;
while (resultSet.next()) {
assertEquals(rowCount, resultSet.getInt(2));
int v = resultSet.getInt(2);
if (rowCount == 99) {
assertTrue(resultSet.wasNull());
} else {
assertEquals(rowCount, v);
}
rowCount++;
}
assertEquals(99, rowCount);
assertEquals(100, rowCount);
}

try (ResultSet resultSet = statement.executeQuery("select time, s1 from dev10")) {
Expand Down Expand Up @@ -518,10 +537,15 @@ public void testInsertAlignedWithEmptyPage3() throws SQLException {
int rowCount = 0;
try (ResultSet resultSet = statement.executeQuery("select s3 from dev13")) {
while (resultSet.next()) {
assertEquals(rowCount + 49, resultSet.getInt(1));
int v = resultSet.getInt(1);
if (rowCount >= 49) {
assertEquals(rowCount, v);
} else {
assertTrue(resultSet.wasNull());
}
rowCount++;
}
assertEquals(51, rowCount);
assertEquals(100, rowCount);
}

try (ResultSet resultSet = statement.executeQuery("select s2 from dev13")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,16 @@ public void testInsertSingleColumn() throws SQLException {

rs1 = st1.executeQuery("select time, ss1, ss2 from sg21 order by time");
assertTrue(rs1.next());
rs1.getString("ss1");
assertTrue(rs1.wasNull());
rs1.getInt("ss2");
assertTrue(rs1.wasNull());

assertTrue(rs1.next());
assertEquals("1", rs1.getString("ss1"));
rs1.getInt("ss2");
assertTrue(rs1.wasNull());
assertTrue(rs1.next());
assertEquals("1", rs1.getString("ss1"));
assertEquals(1, rs1.getInt("ss2"));
assertFalse(rs1.next());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ public void testBigDateTime() {
statement.execute("use " + DATABASE_NAME);

statement.execute(
"insert into table1(time,device_id,s2) values (1618283005586000, 'd1',8.76)");
"insert into table1(time,device_id,s2) values (1618283005586000, 'd2',8.76)");

try (ResultSet resultSet =
statement.executeQuery(
"select time, s2 from table1 where device_id='d1' and time=53251-05-07T17:06:26.000+08:00")) {
"select time, s2 from table1 where device_id='d2' and time=53251-05-07T17:06:26.000+08:00")) {
Assert.assertNotNull(resultSet);
int cnt = 0;
while (resultSet.next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ public void selectWithDuplicatedPathsTest() {
new String[] {
"1970-01-01T00:00:00.001Z,d0,101,101,1101,",
"1970-01-01T00:00:00.002Z,d0,10000,10000,40000,",
"1970-01-01T00:00:00.003Z,d0,null,null,null,",
"1970-01-01T00:00:00.004Z,d0,null,null,null,",
"1970-01-01T00:00:00.050Z,d0,10000,10000,50000,",
"1970-01-01T00:00:00.060Z,d0,null,null,null,",
"1970-01-01T00:00:00.070Z,d0,null,null,null,",
"1970-01-01T00:00:00.080Z,d0,null,null,null,",
"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,",
Expand All @@ -215,15 +220,15 @@ public void selectLimitTest() {
String[] retArray =
new String[] {
"1970-01-01T00:00:00.002Z,d0,10000,10000,40000,",
"1970-01-01T00:00:00.003Z,d0,null,null,null,",
"1970-01-01T00:00:00.004Z,d0,null,null,null,",
"1970-01-01T00:00:00.050Z,d0,10000,10000,50000,",
"1970-01-01T00:00:00.060Z,d0,null,null,null,",
"1970-01-01T00:00:00.070Z,d0,null,null,null,",
"1970-01-01T00:00:00.080Z,d0,null,null,null,",
"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,time offset 1 limit 10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,16 @@ public void selectSomeAlignedWithoutValueFilterTest2() {
"28,null,false",
"29,null,false",
"30,null,false",
"31,null,null",
"32,null,null",
"33,null,null",
"34,null,null",
"35,null,null",
"36,null,null",
"37,null,null",
"38,null,null",
"39,null,null",
"40,null,null",
};

String[] columnNames = {"s1", "s4"};
Expand Down Expand Up @@ -1729,6 +1739,16 @@ public void selectSomeAlignedWithoutValueFilterAlignByDeviceTest2() {
"28,d1,null,false",
"29,d1,null,false",
"30,d1,null,false",
"31,d1,null,null",
"32,d1,null,null",
"33,d1,null,null",
"34,d1,null,null",
"35,d1,null,null",
"36,d1,null,null",
"37,d1,null,null",
"38,d1,null,null",
"39,d1,null,null",
"40,d1,null,null",
};

String[] columnNames = {"Device", "s1", "s4"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public void testRound() {
"1970-01-01T00:00:00.003Z,120.0,",
"1970-01-01T00:00:00.004Z,101.0,",
"1970-01-01T00:00:00.005Z,90.0,",
"1970-01-01T00:00:00.006Z,null,",
"2023-03-13T08:16:19.764Z,121.0,"
};
tableResultSetEqualTest(
Expand All @@ -131,6 +132,7 @@ public void testRound() {
"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.004Z,null,",
"1970-01-01T00:00:00.005Z,21.0,",
"1970-01-01T00:00:00.006Z,61.0,",
"2023-03-13T08:16:19.764Z,10.0,"
Expand Down Expand Up @@ -175,6 +177,7 @@ public void testRoundWithPlaces() {
"1970-01-01T00:00:00.003Z,120.2,",
"1970-01-01T00:00:00.004Z,101.1,",
"1970-01-01T00:00:00.005Z,90.1,",
"1970-01-01T00:00:00.006Z,null,",
"2023-03-13T08:16:19.764Z,120.5,"
};
tableResultSetEqualTest(
Expand All @@ -187,6 +190,7 @@ public void testRoundWithPlaces() {
"1970-01-01T00:00:00.003Z,120.16,",
"1970-01-01T00:00:00.004Z,101.13,",
"1970-01-01T00:00:00.005Z,90.12,",
"1970-01-01T00:00:00.006Z,null,",
"2023-03-13T08:16:19.764Z,120.51,"
};
tableResultSetEqualTest(
Expand All @@ -199,6 +203,7 @@ public void testRoundWithPlaces() {
"1970-01-01T00:00:00.003Z,120.161,",
"1970-01-01T00:00:00.004Z,101.131,",
"1970-01-01T00:00:00.005Z,90.116,",
"1970-01-01T00:00:00.006Z,null,",
"2023-03-13T08:16:19.764Z,120.511,"
};
tableResultSetEqualTest(
Expand All @@ -211,6 +216,7 @@ public void testRoundWithPlaces() {
"1970-01-01T00:00:00.003Z,120.1612,",
"1970-01-01T00:00:00.004Z,101.1312,",
"1970-01-01T00:00:00.005Z,90.1162,",
"1970-01-01T00:00:00.006Z,null,",
"2023-03-13T08:16:19.764Z,120.5112,"
};
tableResultSetEqualTest(
Expand All @@ -221,6 +227,7 @@ public void testRoundWithPlaces() {
"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.004Z,null,",
"1970-01-01T00:00:00.005Z,20.81435,",
"1970-01-01T00:00:00.006Z,60.71443,",
"2023-03-13T08:16:19.764Z,10.14342,"
Expand All @@ -233,6 +240,7 @@ public void testRoundWithPlaces() {
"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.004Z,null,",
"1970-01-01T00:00:00.005Z,20.8,",
"1970-01-01T00:00:00.006Z,60.7,",
"2023-03-13T08:16:19.764Z,10.1,"
Expand Down Expand Up @@ -278,6 +286,7 @@ public void testRoundWithNegativePlaces() {
"1970-01-01T00:00:00.003Z,120.0,",
"1970-01-01T00:00:00.004Z,100.0,",
"1970-01-01T00:00:00.005Z,90.0,",
"1970-01-01T00:00:00.006Z,null,",
"2023-03-13T08:16:19.764Z,120.0,"
};
tableResultSetEqualTest(
Expand All @@ -288,6 +297,7 @@ public void testRoundWithNegativePlaces() {
"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.004Z,null,",
"1970-01-01T00:00:00.005Z,20.0,",
"1970-01-01T00:00:00.006Z,60.0,",
"2023-03-13T08:16:19.764Z,10.0,"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ public void testBlobCompare() {
String[] expectedHeader = new String[] {"s10", "res1", "res2", "res3"};
String[] expectedAns =
new String[] {
"0xabcd,true,true,true,",
"0xabcd,true,true,true,", "null,null,null,null,", "null,null,null,null,",
};
tableResultSetEqualTest(
"select s10, s10 > x'2d' as res1, s10 <> x'2d' as res2, s10 = X'abcd' as res3 from absTable",
Expand All @@ -404,7 +404,7 @@ public void testDateCompare() {
String[] expectedHeader = new String[] {"s7", "res1", "res2", "res3"};
String[] expectedAns =
new String[] {
"2021-10-01,true,true,true,",
"2021-10-01,true,true,true,", "null,null,null,null,", "null,null,null,null,",
};
// add it back while supporting Implicit conversion
// tableResultSetEqualTest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,67 +119,42 @@ public void rawDataQueryTest() {
Arrays.asList(
"SELECT time,s1 FROM vehicle WHERE time<200 limit 3",
"SELECT time,s0 FROM vehicle WHERE s1 > 190 limit 3",
"SELECT time,s1,s2 FROM vehicle WHERE s1 > 190 or s2 < 10.0 limit 3 offset 2",
"SELECT * FROM vehicle slimit 1",
"SELECT * FROM vehicle slimit 1 soffset 2",
"SELECT * FROM vehicle WHERE s1 > 190 or s2 < 10.0 limit 3 offset 1 slimit 1 soffset 2");
"SELECT time,s1,s2 FROM vehicle WHERE s1 > 190 or s2 < 10.0 offset 2 limit 3",
"SELECT time,s2 FROM vehicle WHERE s1 > 190 or s2 < 10.0 offset 1 limit 3");
List<List<String>> expectHeaders =
Arrays.asList(
Arrays.asList("time", "s1"),
Arrays.asList("time", "s0"),
Arrays.asList("time", "s1", "s2"),
Arrays.asList("time", "s0"),
Arrays.asList("time", "s2"),
Arrays.asList("time", "s2"));
List<String[]> retArrays =
Arrays.asList(
new String[] {
defaultFormatDataTime(1) + ",1101,",
defaultFormatDataTime(2) + ",40000,",
defaultFormatDataTime(50) + ",50000,"
defaultFormatDataTime(3) + ",null,",
},
new String[] {
defaultFormatDataTime(1) + ",101,",
defaultFormatDataTime(2) + ",10000,",
defaultFormatDataTime(50) + ",10000,"
},
new String[] {
defaultFormatDataTime(1) + ",null,3.33,",
defaultFormatDataTime(3) + ",null,3.33,",
defaultFormatDataTime(4) + ",null,4.44,",
defaultFormatDataTime(50) + ",50000,null,"
},
new String[] {
defaultFormatDataTime(1) + ",101,",
defaultFormatDataTime(2) + ",10000,",
defaultFormatDataTime(1) + ",10000,",
defaultFormatDataTime(100) + ",99,",
defaultFormatDataTime(101) + ",99,",
defaultFormatDataTime(102) + ",80,",
defaultFormatDataTime(103) + ",99,",
defaultFormatDataTime(104) + ",90,",
defaultFormatDataTime(105) + ",99,",
defaultFormatDataTime(106) + ",99,",
defaultFormatDataTime(1000) + ",22222,"
},
new String[] {
defaultFormatDataTime(2) + ",2.22,",
defaultFormatDataTime(3) + ",3.33,",
defaultFormatDataTime(4) + ",4.44,",
defaultFormatDataTime(102) + ",10.0,",
defaultFormatDataTime(105) + ",11.11,",
defaultFormatDataTime(1000) + ",1000.11,"
},
new String[] {
defaultFormatDataTime(3) + ",3.33,",
defaultFormatDataTime(4) + ",4.44,",
defaultFormatDataTime(105) + ",11.11,"
});

for (int i = 0; i < querySQLs.size(); i++) {
tableResultSetEqualTest(
querySQLs.get(0),
expectHeaders.get(0).toArray(new String[0]),
retArrays.get(0),
querySQLs.get(i),
expectHeaders.get(i).toArray(new String[0]),
retArrays.get(i),
DATABASE_NAME);
}
}
Expand Down
Loading

0 comments on commit f227d9a

Please sign in to comment.