|
1 | 1 | package com.clickhouse.data; |
2 | 2 |
|
3 | 3 | import java.math.BigInteger; |
| 4 | +import java.util.Arrays; |
4 | 5 | import java.util.Collections; |
5 | 6 | import java.util.LinkedList; |
6 | 7 | import java.util.List; |
| 8 | +import java.util.Map; |
7 | 9 |
|
8 | 10 | import org.testng.Assert; |
9 | 11 | import org.testng.annotations.DataProvider; |
@@ -441,4 +443,26 @@ public boolean isWidenUnsignedTypes() { |
441 | 443 | } |
442 | 444 | } |
443 | 445 | } |
| 446 | + |
| 447 | + @Test(groups = {"unit"}, dataProvider = "testJSONBinaryFormat_dp") |
| 448 | + public void testJSONBinaryFormat(String jsonDef, int params, List<String> predefinedPaths) throws Exception { |
| 449 | + ClickHouseColumn column = ClickHouseColumn.of("v", jsonDef); |
| 450 | + Assert.assertEquals(column.getNestedColumns().size(), predefinedPaths.size(), "predefined paths count mismatch"); |
| 451 | + Assert.assertEquals(column.getParameters().size(), params, "parameters count mismatch"); |
| 452 | + } |
| 453 | + |
| 454 | + @DataProvider |
| 455 | + public Object[][] testJSONBinaryFormat_dp() { |
| 456 | + |
| 457 | + return new Object[][] { |
| 458 | + {"JSON", 0, Collections.emptyList()}, |
| 459 | + {"JSON()", 0, Collections.emptyList()}, |
| 460 | + {"JSON(stat.name String, count Int32)", 0, Arrays.asList("stat.name", "count")}, |
| 461 | + {"JSON(stat.name String, `comments` String)", 0, Arrays.asList("stat.name", "comments")}, |
| 462 | + {"JSON(max_dynamic_paths=3, stat.name String, count Int8, SKIP alt_count)", 1, Arrays.asList("stat.name", "count")}, |
| 463 | + {"JSON(max_dynamic_paths=3, stat.name String, SKIP REGEXP '^-.*')", 1, Arrays.asList("stat.name")}, |
| 464 | + {"JSON(max_dynamic_paths=3,SKIP REGEXP '^-.*',SKIP ff, flags Array(Array(Array(Int8))), SKIP alt_count)", 1, Arrays.asList("flags")}, |
| 465 | + {"JSON(max_dynamic_types=3,max_dynamic_paths=3, SKIP REGEXP '^-.*',SKIP ff, flags Array(Array(Array(Int8))), SKIP alt_count)", 2, Arrays.asList("flags")}, |
| 466 | + }; |
| 467 | + } |
444 | 468 | } |
0 commit comments