Skip to content

Commit 5e89949

Browse files
author
Paultagoras
committed
Update RowBinaryFormatWriterTest.java
1 parent 94613eb commit 5e89949

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

client-v2/src/test/java/com/clickhouse/client/datatypes/RowBinaryFormatWriterTest.java

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
import java.time.temporal.ChronoUnit;
3030
import java.time.temporal.TemporalUnit;
3131
import java.util.ArrayList;
32+
import java.util.Arrays;
33+
import java.util.HashMap;
3234
import java.util.List;
3335
import java.util.Map;
3436
import java.util.Objects;
@@ -78,6 +80,10 @@ protected void initTable(String tableName, String createTableSQL, CommandSetting
7880
settings = new CommandSettings();
7981
}
8082

83+
settings.serverSetting("allow_experimental_dynamic_type", "1");
84+
settings.serverSetting("allow_experimental_json_type", "1");
85+
settings.serverSetting("allow_experimental_variant_type", "1");
86+
8187
client.execute("DROP TABLE IF EXISTS " + tableName, settings).get(EXECUTE_CMD_TIMEOUT, TimeUnit.SECONDS);
8288
client.execute(createTableSQL, settings).get(EXECUTE_CMD_TIMEOUT, TimeUnit.SECONDS);
8389
}
@@ -92,11 +98,11 @@ private static void assertEqualsKinda(Object actual, Object expected) {
9298
}
9399

94100
if (actual instanceof Object[]) {
95-
actual = List.of((Object[]) actual);
101+
actual = Arrays.asList((Object[]) actual);
96102
}
97103

98104
if (expected instanceof Object[]) {
99-
expected = List.of((Object[]) expected);
105+
expected = Arrays.asList((Object[]) expected);
100106
}
101107

102108
if (actual instanceof BinaryStreamReader.ArrayValue) {
@@ -380,7 +386,7 @@ public void writeTupleTests() throws Exception {
380386
// Insert random (valid) values
381387
Field[][] rows = new Field[][] {{
382388
new Field("id", 1), //Row ID
383-
new Field("tuple", List.of((byte) 1, (short) 2)).set(new Object[]{(byte) 1, (short) 2}), new Field("tuple_default").set(List.of((byte) 3, (short) 4)) //Tuple
389+
new Field("tuple", Arrays.asList((byte) 1, (short) 2)).set(new Object[]{(byte) 1, (short) 2}), new Field("tuple_default").set(Arrays.asList((byte) 3, (short) 4)) //Tuple
384390
}
385391
};
386392

@@ -417,7 +423,7 @@ public void writeArrayTests() throws Exception {
417423
// Insert random (valid) values
418424
Field[][] rows = new Field[][] {{
419425
new Field("id", 1), //Row ID
420-
new Field("array", List.of((byte) 1, (byte) 2)).set(new Object[]{(byte) 1, (byte) 2}), new Field("array_default").set(List.of((byte) 3)) //Array
426+
new Field("array", Arrays.asList((byte) 1, (byte) 2)).set(new Object[]{(byte) 1, (byte) 2}), new Field("array_default").set(Arrays.asList((byte) 3)) //Array
421427
}
422428
};
423429

@@ -440,12 +446,12 @@ public void writeGeometryTests() throws Exception {
440446
// Insert random (valid) values
441447
Field[][] rows = new Field[][] {{
442448
new Field("id", 1), //Row ID
443-
new Field("point", List.of(1.0, 2.0)).set(List.of(1.0, 2.0)), new Field("point_default").set(List.of(0.0, 0.0)),
444-
new Field("ring", List.of(List.of(1.0, 2.0), List.of(3.0, 4.0))).set(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0))), new Field("ring_default").set(List.of(List.of(0.0, 0.0), List.of(10.0, 0.0), List.of(10.0, 10.0), List.of(0.0, 10.0))),
445-
new Field("linestring", List.of(List.of(1.0, 2.0), List.of(3.0, 4.0))).set(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0))), new Field("linestring_default").set(List.of(List.of(0.0, 0.0), List.of(10.0, 0.0), List.of(10.0, 10.0), List.of(0.0, 10.0))),
446-
new Field("polygon", List.of(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0)))).set(List.of(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0)))) , new Field("polygon_default").set(List.of(List.of(List.of(0.0, 0.0), List.of(10.0, 0.0), List.of(10.0, 10.0), List.of(0.0, 10.0)))) ,
447-
new Field("multilinestring", List.of(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0)))).set(List.of(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0)))) , new Field("multilinestring_default").set(List.of(List.of(List.of(0.0, 0.0), List.of(10.0, 0.0), List.of(10.0, 10.0), List.of(0.0, 10.0)))) ,
448-
new Field("multipolygon", List.of(List.of(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0))))).set(List.of(List.of(List.of(List.of(1.0, 2.0), List.of(3.0, 4.0))))) , new Field("multipolygon_default").set(List.of(List.of(List.of(List.of(0.0, 0.0), List.of(10.0, 0.0), List.of(10.0, 10.0), List.of(0.0, 10.0))))),
449+
new Field("point", Arrays.asList(1.0, 2.0)).set(Arrays.asList(1.0, 2.0)), new Field("point_default").set(Arrays.asList(0.0, 0.0)),
450+
new Field("ring", Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0))).set(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0))), new Field("ring_default").set(Arrays.asList(Arrays.asList(0.0, 0.0), Arrays.asList(10.0, 0.0), Arrays.asList(10.0, 10.0), Arrays.asList(0.0, 10.0))),
451+
new Field("linestring", Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0))).set(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0))), new Field("linestring_default").set(Arrays.asList(Arrays.asList(0.0, 0.0), Arrays.asList(10.0, 0.0), Arrays.asList(10.0, 10.0), Arrays.asList(0.0, 10.0))),
452+
new Field("polygon", Arrays.asList(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0)))).set(Arrays.asList(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0)))) , new Field("polygon_default").set(Arrays.asList(Arrays.asList(Arrays.asList(0.0, 0.0), Arrays.asList(10.0, 0.0), Arrays.asList(10.0, 10.0), Arrays.asList(0.0, 10.0)))) ,
453+
new Field("multilinestring", Arrays.asList(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0)))).set(Arrays.asList(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0)))) , new Field("multilinestring_default").set(Arrays.asList(Arrays.asList(Arrays.asList(0.0, 0.0), Arrays.asList(10.0, 0.0), Arrays.asList(10.0, 10.0), Arrays.asList(0.0, 10.0)))) ,
454+
new Field("multipolygon", Arrays.asList(Arrays.asList(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0))))).set(Arrays.asList(Arrays.asList(Arrays.asList(Arrays.asList(1.0, 2.0), Arrays.asList(3.0, 4.0))))) , new Field("multipolygon_default").set(Arrays.asList(Arrays.asList(Arrays.asList(Arrays.asList(0.0, 0.0), Arrays.asList(10.0, 0.0), Arrays.asList(10.0, 10.0), Arrays.asList(0.0, 10.0))))),
449455
}};
450456

451457
writeTest(tableName, tableCreate, rows);
@@ -462,10 +468,14 @@ public void writeMapTests() throws Exception {
462468
" map Map(String, Int16) " +
463469
" ) Engine = MergeTree ORDER BY id";
464470

471+
Map<String, Integer> tmpMap = new HashMap<>();
472+
tmpMap.put("a", 1);
473+
tmpMap.put("b", 2);
474+
465475
// Insert random (valid) values
466476
Field[][] rows = new Field[][] {{
467477
new Field("id", 1), //Row ID
468-
new Field("map", Map.of((byte) 1, (short) 2)).set(Map.of((byte) 1, (short) 2)), //Map
478+
new Field("map", tmpMap).set(tmpMap), //Map
469479
}
470480
};
471481

@@ -483,8 +493,8 @@ public void writeNestedTests() throws Exception {
483493
// Insert random (valid) values
484494
Field[][] rows = new Field[][] {{
485495
new Field("id", 1), //Row ID
486-
new Field("nested.n1", List.of(1)).set(List.of(1)), //Nested
487-
new Field("nested.n2", List.of(2)).set(List.of(2)), //Nested
496+
new Field("nested.n1", Arrays.asList(1)).set(Arrays.asList(1)), //Nested
497+
new Field("nested.n2", Arrays.asList(2)).set(Arrays.asList(2)), //Nested
488498
}
489499
};
490500

@@ -560,7 +570,7 @@ public void writeAggregateFunctionTests() throws Exception {
560570
// Insert random (valid) values
561571
Field[][] rows = new Field[][] {{
562572
new Field("id", 1), //Row ID
563-
new Field("aggregate_function", List.of((byte) 1)).set(List.of((byte) 1)), //AggregateFunction
573+
new Field("aggregate_function", Arrays.asList((byte) 1)).set(Arrays.asList((byte) 1)), //AggregateFunction
564574
}
565575
};
566576

@@ -580,7 +590,7 @@ public void writeSimpleAggregateFunctionTests() throws Exception {
580590
// Insert random (valid) values
581591
Field[][] rows = new Field[][] {{
582592
new Field("id", 1), //Row ID
583-
new Field("simple_aggregate_function", List.of((byte) 1)).set(List.of((byte) 1)), //SimpleAggregateFunction
593+
new Field("simple_aggregate_function", Arrays.asList((byte) 1)).set(Arrays.asList((byte) 1)), //SimpleAggregateFunction
584594
}
585595
};
586596

@@ -589,7 +599,7 @@ public void writeSimpleAggregateFunctionTests() throws Exception {
589599

590600

591601
//TODO: Currently experimental
592-
@Test (groups = { "integration" }, enabled = false)
602+
@Test (groups = { "integration" })
593603
public void writeDynamicTests() throws Exception {
594604
String tableName = "rowBinaryFormatWriterTest_writeDynamicTests_" + UUID.randomUUID().toString().replace('-', '_');
595605
String tableCreate = "CREATE TABLE \"" + tableName + "\" " +
@@ -600,7 +610,7 @@ public void writeDynamicTests() throws Exception {
600610
// Insert random (valid) values
601611
Field[][] rows = new Field[][] {{
602612
new Field("id", 1), //Row ID
603-
new Field("dynamic", List.of((byte) 1, (short) 2)).set(List.of((byte) 1, (short) 2)), //Dynamic
613+
new Field("dynamic", Arrays.asList((byte) 1, (short) 2)).set(Arrays.asList((byte) 1, (short) 2)), //Dynamic
604614
}
605615
};
606616

@@ -610,7 +620,7 @@ public void writeDynamicTests() throws Exception {
610620

611621

612622
//TODO: Currently experimental
613-
@Test (groups = { "integration" }, enabled = false)
623+
@Test (groups = { "integration" })
614624
public void writeJsonTests() throws Exception {
615625
String tableName = "rowBinaryFormatWriterTest_writeJsonTests_" + UUID.randomUUID().toString().replace('-', '_');
616626
String tableCreate = "CREATE TABLE \"" + tableName + "\" " +
@@ -622,15 +632,14 @@ public void writeJsonTests() throws Exception {
622632
Field[][] rows = new Field[][] {{
623633
new Field("id", 1), //Row ID
624634
new Field("json", "{\"a\": 1}").set("{\"a\": 1}"), new Field("json_default").set("{\"a\": 1}") //Json
625-
}
626-
};
635+
}};
627636

628637
writeTest(tableName, tableCreate, rows);
629638
}
630639

631640

632641
//TODO: Currently experimental
633-
@Test (groups = { "integration" }, enabled = false)
642+
@Test (groups = { "integration" })
634643
public void writeVariantTests() throws Exception {
635644
String tableName = "rowBinaryFormatWriterTest_writeVariantTests_" + UUID.randomUUID().toString().replace('-', '_');
636645
String tableCreate = "CREATE TABLE \"" + tableName + "\" " +

0 commit comments

Comments
 (0)