Skip to content

Commit 48cc994

Browse files
authored
Merge pull request #2321 from ClickHouse/simple-aggregate-tests
Update DataTypeTests.java
2 parents 63be1b9 + 3f81ef8 commit 48cc994

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

jdbc-v2/src/test/java/com/clickhouse/jdbc/DataTypeTests.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import static org.testng.Assert.assertEquals;
3838
import static org.testng.Assert.assertFalse;
39+
import static org.testng.Assert.assertNull;
3940
import static org.testng.Assert.assertTrue;
4041

4142

@@ -677,9 +678,10 @@ public void testLowCardinalityTypeSimpleStatement() throws SQLException {
677678

678679
@Test(groups = { "integration" })
679680
public void testSimpleAggregateFunction() throws SQLException {
680-
runQuery("CREATE TABLE test_aggregate (order Int8, "
681-
+ "int8 Int8"
682-
+ ") ENGINE = MergeTree ORDER BY ()");
681+
runQuery("CREATE TABLE test_aggregate (order Int8," +
682+
" int8 Int8," +
683+
" val SimpleAggregateFunction(any, Nullable(Int8))" +
684+
") ENGINE = MergeTree ORDER BY ()");
683685

684686
// Insert random (valid) values
685687
long seed = System.currentTimeMillis();
@@ -688,9 +690,9 @@ public void testSimpleAggregateFunction() throws SQLException {
688690

689691
int int8 = rand.nextInt(256) - 128;
690692

691-
insertData(String.format("INSERT INTO test_aggregate VALUES ( 1, %d )", int8));
692-
insertData(String.format("INSERT INTO test_aggregate VALUES ( 2, %d )", int8));
693-
insertData(String.format("INSERT INTO test_aggregate VALUES ( 3, %d )", int8));
693+
insertData(String.format("INSERT INTO test_aggregate VALUES ( 1, %d, null )", int8));
694+
insertData(String.format("INSERT INTO test_aggregate VALUES ( 2, %d, null )", int8));
695+
insertData(String.format("INSERT INTO test_aggregate VALUES ( 3, %d, null )", int8));
694696

695697
// Check the results
696698
try (Connection conn = getConnection()) {
@@ -699,6 +701,11 @@ public void testSimpleAggregateFunction() throws SQLException {
699701
assertTrue(rs.next());
700702
assertEquals(rs.getInt(1), int8 * 3);
701703
}
704+
try (ResultSet rs = stmt.executeQuery("SELECT any(val) FROM test_aggregate")) {
705+
assertTrue(rs.next());
706+
assertNull(rs.getObject(1));
707+
assertTrue(rs.wasNull());
708+
}
702709
}
703710
}
704711
}

0 commit comments

Comments
 (0)