Skip to content

Commit e9a3bc7

Browse files
committed
Improve UT to support CH 21.3
1 parent 45acb4e commit e9a3bc7

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHousePreparedStatementTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ public void testBatchInput() throws SQLException {
6565
stmt.setObject(4, v[3]);
6666
stmt.addBatch();
6767
}
68-
stmt.executeBatch();
68+
int[] results = stmt.executeBatch();
69+
Assert.assertEquals(results.length, objs.length);
70+
for (int result : results) {
71+
Assert.assertNotEquals(result, PreparedStatement.EXECUTE_FAILED);
72+
}
6973

7074
try (ResultSet rs = s.executeQuery("select * from test_batch_input order by id")) {
7175
Object[][] values = new Object[objs.length][];
@@ -126,6 +130,10 @@ public void testQueryWithExternalTable() throws SQLException {
126130
public void testArrayParameter(String t, Object v) throws SQLException {
127131
try (ClickHouseConnection conn = newConnection(new Properties());
128132
PreparedStatement stmt = conn.prepareStatement("select ?::?")) {
133+
if (conn.getServerVersion().check("(,21.3]")) {
134+
return;
135+
}
136+
129137
stmt.setObject(1, v);
130138
// stmt.setString(2, t) or stmt.setObject(2, t) will result in quoted string
131139
stmt.setObject(2, new StringBuilder(t));

clickhouse-jdbc/src/test/java/com/clickhouse/jdbc/ClickHouseResultSetTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public void testArray() throws SQLException {
3333
try (ClickHouseConnection conn = newConnection(new Properties());
3434
Statement stmt = conn.createStatement()) {
3535
ResultSet rs = stmt.executeQuery(
36-
"select [1,2,3] v1, ['a','b', 'c'] v2, arrayZip(v1, v2) v3, ['2021-11-01 01:02:03', '2021-11-02 02:03:04']::Array(DateTime32) as v4");
36+
"select [1,2,3] v1, ['a','b', 'c'] v2, arrayZip(v1, v2) v3, cast(['2021-11-01 01:02:03', '2021-11-02 02:03:04'] as Array(DateTime32)) v4");
3737
Assert.assertTrue(rs.next());
3838

3939
Assert.assertEquals(rs.getObject(1), new short[] { 1, 2, 3 });
@@ -66,7 +66,7 @@ public void testTuple() throws SQLException {
6666
Statement stmt = conn.createStatement()) {
6767
ResultSet rs = stmt
6868
.executeQuery(
69-
"select (1::Int16, 'a', 1.2::Float32, [1,2]::Array(Nullable(UInt8)), map(toUInt32(1),'a')) v");
69+
"select (toInt16(1), 'a', toFloat32(1.2), cast([1,2] as Array(Nullable(UInt8))), map(toUInt32(1),'a')) v");
7070
Assert.assertTrue(rs.next());
7171
List<?> v = rs.getObject(1, List.class);
7272
Assert.assertEquals(v.size(), 5);

0 commit comments

Comments
 (0)