|
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.ClickHouseSslMode; |
7 | 6 | import com.clickhouse.config.ClickHouseBufferingMode;
|
8 | 7 | import com.clickhouse.config.ClickHouseOption;
|
9 | 8 | import com.clickhouse.config.ClickHouseRenameMethod;
|
|
44 | 43 | import com.clickhouse.data.value.UnsignedShort;
|
45 | 44 |
|
46 | 45 | import org.apache.commons.compress.compressors.lz4.FramedLZ4CompressorInputStream;
|
47 |
| -import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils; |
48 | 46 | import org.testng.Assert;
|
49 | 47 | import org.testng.SkipException;
|
50 | 48 | import org.testng.annotations.DataProvider;
|
@@ -294,7 +292,12 @@ protected Object[][] getPrimitiveArrayMatrix() {
|
294 | 292 | UnsignedLong.valueOf(5L) } },
|
295 | 293 | { "Nullable(Float32)", new Float[] { null, -2F, 3F, -4F, 5F } },
|
296 | 294 | { "Nullable(Float64)", new Double[] { 1D, null, 3D, -4D, 5D } },
|
| 295 | + }; |
| 296 | + } |
297 | 297 |
|
| 298 | + @DataProvider(name = "primitiveArrayLowCardinalityMatrix") |
| 299 | + protected Object[][] getPrimitiveArrayLowCardinalityMatrix() { |
| 300 | + return new Object[][]{ |
298 | 301 | { "LowCardinality(Int8)", new int[] { -1, 2, -3, 4, -5 } },
|
299 | 302 | { "LowCardinality(UInt8)", new int[] { 1, 2, 3, 4, 5 } },
|
300 | 303 | { "LowCardinality(Int16)", new int[] { -1, 2, -3, 4, -5 } },
|
@@ -710,6 +713,41 @@ public void testPrimitiveArray(String baseType, Object expectedValues) throws Cl
|
710 | 713 | ClickHouseColumn.of("", baseType)).newArrayValue(server.config).update(expectedValues)
|
711 | 714 | .toSqlExpression()));
|
712 | 715 |
|
| 716 | + checkPrimitiveArrayValues(server, tableName, tableColumns, baseType, expectedValues); |
| 717 | + } |
| 718 | + |
| 719 | + @Test(dataProvider = "primitiveArrayLowCardinalityMatrix", groups = "integration") |
| 720 | + public void testPrimitiveArrayWithLowCardinality(String baseType, Object expectedValues) throws ClickHouseException { |
| 721 | + ClickHouseNode server = getServer(); |
| 722 | + |
| 723 | + String tableName = "test_primitive_array_" |
| 724 | + + baseType.replace('(', '_').replace(')', ' ').trim().toLowerCase(); |
| 725 | + String tableColumns = String.format("a1 Array(%1$s), a2 Array(Array(%1$s)), a3 Array(Array(Array(%1$s)))", |
| 726 | + baseType); |
| 727 | + try { |
| 728 | + sendAndWait(server, "drop table if exists " + tableName, |
| 729 | + "create table " + tableName + " (" + tableColumns + ")engine=Memory", |
| 730 | + "insert into " + tableName + String.format( |
| 731 | + " values(%2$s, [[123],[],[4], %2$s], [[[12],[3],[],[4,5]],[[123],[],[4], %2$s]])", baseType, |
| 732 | + ClickHouseColumn.of("", ClickHouseDataType.Array, false, |
| 733 | + ClickHouseColumn.of("", baseType)).newArrayValue(server.config).update(expectedValues) |
| 734 | + .toSqlExpression())); |
| 735 | + } catch (ClickHouseException e) { |
| 736 | + try (ClickHouseClient client = getClient()) { |
| 737 | + if (e.getErrorCode() == ClickHouseException.ERROR_SUSPICIOUS_TYPE_FOR_LOW_CARDINALITY && |
| 738 | + checkServerVersion(client, server, "[24.2,)")) { |
| 739 | + return; |
| 740 | + } |
| 741 | + } catch ( Exception e1) { |
| 742 | + Assert.fail("Failed to check server version", e1); |
| 743 | + } |
| 744 | + |
| 745 | + Assert.fail("Exception code is " + e.getErrorCode(), e); |
| 746 | + } |
| 747 | + checkPrimitiveArrayValues(server, tableName, tableColumns, baseType, expectedValues); |
| 748 | + } |
| 749 | + |
| 750 | + private void checkPrimitiveArrayValues(ClickHouseNode server, String tableName, String tableColumns, String baseType, Object expectedValues) throws ClickHouseException { |
713 | 751 | try (ClickHouseClient client = getClient()) {
|
714 | 752 | ClickHouseRequest<?> request = newRequest(client, server)
|
715 | 753 | .format(ClickHouseFormat.RowBinaryWithNamesAndTypes);
|
@@ -762,6 +800,7 @@ public void testPrimitiveArray(String baseType, Object expectedValues) throws Cl
|
762 | 800 | }
|
763 | 801 | }
|
764 | 802 |
|
| 803 | + |
765 | 804 | @Test(groups = { "integration" })
|
766 | 805 | public void testQueryWithNoResult() throws ExecutionException, InterruptedException {
|
767 | 806 | String sql = "select * from system.numbers limit 0";
|
|
0 commit comments