|
3 | 3 | import com.clickhouse.client.api.ClientConfigProperties;
|
4 | 4 | import com.clickhouse.client.api.DataTypeUtils;
|
5 | 5 | import com.clickhouse.client.api.internal.ServerSettings;
|
| 6 | +import com.clickhouse.client.api.sql.SQLUtils; |
6 | 7 | import com.clickhouse.data.ClickHouseVersion;
|
7 | 8 | import com.clickhouse.data.Tuple;
|
8 | 9 | import org.slf4j.Logger;
|
|
47 | 48 |
|
48 | 49 | import static org.testng.Assert.assertEquals;
|
49 | 50 | import static org.testng.Assert.assertFalse;
|
| 51 | +import static org.testng.Assert.assertNotEquals; |
50 | 52 | import static org.testng.Assert.assertNull;
|
51 | 53 | import static org.testng.Assert.assertThrows;
|
52 | 54 | import static org.testng.Assert.assertTrue;
|
@@ -1372,7 +1374,32 @@ public void testJSONWritingAsString() throws SQLException {
|
1372 | 1374 | }
|
1373 | 1375 | }
|
1374 | 1376 |
|
1375 |
| - @Test(groups = { "integration" }, enabled = false) |
| 1377 | + @Test(groups = { "integration" }) |
| 1378 | + public void testReadingJSONBinary() throws SQLException { |
| 1379 | + if (ClickHouseVersion.of(getServerVersion()).check("(,24.8]")) { |
| 1380 | + return; // JSON was introduced in 24.10 |
| 1381 | + } |
| 1382 | + |
| 1383 | + Properties properties = new Properties(); |
| 1384 | + properties.put(ClientConfigProperties.serverSetting("allow_experimental_json_type"), "1"); |
| 1385 | + try (Connection conn = getJdbcConnection(properties); |
| 1386 | + Statement stmt = conn.createStatement()) { |
| 1387 | + |
| 1388 | + final String json = "{\"count\": 1000, \"event\": { \"name\": \"start\", \"value\": 0.10} }"; |
| 1389 | + String sql = String.format("SELECT %1$s::JSON(), %1$s::JSON(count Int16)", SQLUtils.enquoteLiteral(json)); |
| 1390 | + try (ResultSet rs = stmt.executeQuery(sql)) { |
| 1391 | + rs.next(); |
| 1392 | + |
| 1393 | + Map<String, Object> val1 = (Map<String, Object>) rs.getObject(1); |
| 1394 | + assertEquals(val1.get("count"), 1000L); |
| 1395 | + Map<String, Object> val2 = (Map<String, Object>) rs.getObject(2); |
| 1396 | + assertEquals(val2.get("count"), (short)1000); |
| 1397 | + } |
| 1398 | + } |
| 1399 | + } |
| 1400 | + |
| 1401 | + |
| 1402 | + @Test(groups = { "integration" }, enabled = false) |
1376 | 1403 | public void testGeometricTypesSimpleStatement() throws SQLException {
|
1377 | 1404 | // TODO: add LineString and MultiLineString support
|
1378 | 1405 | runQuery("CREATE TABLE test_geometric (order Int8, "
|
|
0 commit comments