|
3 | 3 | import com.clickhouse.client.ClickHouseClientBuilder.Agent; |
4 | 4 | import com.clickhouse.client.ClickHouseTransaction.XID; |
5 | 5 | import com.clickhouse.client.config.ClickHouseClientOption; |
| 6 | +import com.clickhouse.client.config.ClickHouseDefaults; |
6 | 7 | import com.clickhouse.config.ClickHouseBufferingMode; |
7 | 8 | import com.clickhouse.config.ClickHouseOption; |
8 | 9 | import com.clickhouse.config.ClickHouseRenameMethod; |
|
71 | 72 | import java.nio.file.Paths; |
72 | 73 | import java.util.ArrayList; |
73 | 74 | import java.util.Collections; |
| 75 | +import java.util.HashMap; |
74 | 76 | import java.util.List; |
75 | 77 | import java.util.Map; |
76 | 78 | import java.util.Map.Entry; |
@@ -2023,26 +2025,21 @@ public void testErrorDuringInsert() throws ClickHouseException { |
2023 | 2025 |
|
2024 | 2026 | @Test(groups = "integration") |
2025 | 2027 | public void testErrorDuringQuery() throws ClickHouseException { |
| 2028 | + // Note: server may return no records but only error |
2026 | 2029 | ClickHouseNode server = getServer(); |
2027 | | - String query = "select number, throwIf(number>=10000000) from numbers(500000000)"; |
2028 | | - long count = 0L; |
| 2030 | + String query = "select number, throwIf(number>=10000) from numbers(12000)"; |
| 2031 | + Map<ClickHouseOption, Object> options = new HashMap<>(); |
2029 | 2032 | try (ClickHouseClient client = getClient(); |
2030 | 2033 | ClickHouseResponse resp = newRequest(client, server) |
2031 | | - .format(ClickHouseFormat.RowBinaryWithNamesAndTypes) |
| 2034 | + .format(ClickHouseFormat.TabSeparated) |
2032 | 2035 | .query(query).executeAndWait()) { |
2033 | | - for (ClickHouseRecord r : resp.records()) { |
2034 | | - // does not work which may relate to deserialization failure |
2035 | | - // java.lang.AssertionError: expected [99764115] but found [4121673519155408707] |
2036 | | - // Assert.assertEquals(r.getValue(0).asLong(), count++); |
2037 | | - Assert.assertTrue((count = r.getValue(0).asLong()) >= 0); |
2038 | | - } |
2039 | 2036 | Assert.fail("Query should be terminated before all rows returned"); |
2040 | 2037 | } catch (UncheckedIOException e) { |
2041 | 2038 | Assert.assertTrue(e.getCause() instanceof IOException, |
2042 | 2039 | "Should end up with IOException due to deserialization failure"); |
| 2040 | + } catch (ClickHouseException e) { |
| 2041 | + Assert.assertEquals(e.getErrorCode(), 395, "Expected error code 395 but we got: " + e.getErrorCode()); |
2043 | 2042 | } |
2044 | | - |
2045 | | - Assert.assertNotEquals(count, 0L, "Should have read at least one record"); |
2046 | 2043 | } |
2047 | 2044 |
|
2048 | 2045 | @Test(groups = "integration") |
|
0 commit comments