Add tests

This commit is contained in:
avogar 2022-05-06 16:51:12 +00:00
parent 3a13c3e372
commit cd8600c583
2 changed files with 341 additions and 0 deletions

View File

@ -0,0 +1,223 @@
JSONColumns
{
"a": [0, 1],
"b": ["String", "String"],
"c": [[[[],"String"],[[],"gnirtS"]], [[[0],"String"],[[0],"gnirtS"]]]
}
{
"a": [2, 3],
"b": ["String", "String"],
"c": [[[[0,1],"String"],[[0,1],"gnirtS"]], [[[],"String"],[[0,1,2],"gnirtS"]]]
}
{
"a": [4],
"b": ["String"],
"c": [[[[0],"String"],[[],"gnirtS"]]]
}
a Nullable(Float64)
b Nullable(String)
c Array(Tuple(Array(Nullable(Float64)), Nullable(String)))
0 String [([],'String'),([],'gnirtS')]
1 String [([0],'String'),([0],'gnirtS')]
2 String [([0,1],'String'),([0,1],'gnirtS')]
3 String [([],'String'),([0,1,2],'gnirtS')]
4 String [([0],'String'),([],'gnirtS')]
JSONColumnsMonoBlock
{
"a": [0, 1, 2, 3, 4],
"b": ["String", "String", "String", "String", "String"],
"c": [[[[],"String"],[[],"gnirtS"]], [[[0],"String"],[[0],"gnirtS"]], [[[0,1],"String"],[[0,1],"gnirtS"]], [[[],"String"],[[0,1,2],"gnirtS"]], [[[0],"String"],[[],"gnirtS"]]]
}
a Nullable(Float64)
b Nullable(String)
c Array(Tuple(Array(Nullable(Float64)), Nullable(String)))
0 String [([],'String'),([],'gnirtS')]
1 String [([0],'String'),([0],'gnirtS')]
2 String [([0,1],'String'),([0,1],'gnirtS')]
3 String [([],'String'),([0,1,2],'gnirtS')]
4 String [([0],'String'),([],'gnirtS')]
JSONColumnsMonoBlock 3 rows
{
"a": [0, 1, 2],
"b": ["String", "String", "String"],
"c": [[[[],"String"],[[],"gnirtS"]], [[[0],"String"],[[0],"gnirtS"]], [[[0,1],"String"],[[0,1],"gnirtS"]]]
}
a Nullable(Float64)
b Nullable(String)
c Array(Tuple(Array(Nullable(Float64)), Nullable(String)))
0 String [([],'String'),([],'gnirtS')]
1 String [([0],'String'),([0],'gnirtS')]
2 String [([0,1],'String'),([0,1],'gnirtS')]
JSONCompactColumns
[
[0, 1],
["String", "String"],
[[[[],"String"],[[],"gnirtS"]], [[[0],"String"],[[0],"gnirtS"]]]
]
[
[2, 3],
["String", "String"],
[[[[0,1],"String"],[[0,1],"gnirtS"]], [[[],"String"],[[0,1,2],"gnirtS"]]]
]
[
[4],
["String"],
[[[[0],"String"],[[],"gnirtS"]]]
]
c1 Nullable(Float64)
c2 Nullable(String)
c3 Array(Tuple(Array(Nullable(Float64)), Nullable(String)))
0 String [([],'String'),([],'gnirtS')]
1 String [([0],'String'),([0],'gnirtS')]
2 String [([0,1],'String'),([0,1],'gnirtS')]
3 String [([],'String'),([0,1,2],'gnirtS')]
4 String [([0],'String'),([],'gnirtS')]
JSONCompactColumnsMonoBlock
[
[0, 1, 2, 3, 4],
["String", "String", "String", "String", "String"],
[[[[],"String"],[[],"gnirtS"]], [[[0],"String"],[[0],"gnirtS"]], [[[0,1],"String"],[[0,1],"gnirtS"]], [[[],"String"],[[0,1,2],"gnirtS"]], [[[0],"String"],[[],"gnirtS"]]]
]
c1 Nullable(Float64)
c2 Nullable(String)
c3 Array(Tuple(Array(Nullable(Float64)), Nullable(String)))
0 String [([],'String'),([],'gnirtS')]
1 String [([0],'String'),([0],'gnirtS')]
2 String [([0,1],'String'),([0,1],'gnirtS')]
3 String [([],'String'),([0,1,2],'gnirtS')]
4 String [([0],'String'),([],'gnirtS')]
JSONCompactColumnsMonoBlock 3 rows
[
[0, 1, 2],
["String", "String", "String"],
[[[[],"String"],[[],"gnirtS"]], [[[0],"String"],[[0],"gnirtS"]], [[[0,1],"String"],[[0,1],"gnirtS"]]]
]
c1 Nullable(Float64)
c2 Nullable(String)
c3 Array(Tuple(Array(Nullable(Float64)), Nullable(String)))
0 String [([],'String'),([],'gnirtS')]
1 String [([0],'String'),([0],'gnirtS')]
2 String [([0,1],'String'),([0,1],'gnirtS')]
JSONColumnsWithMetadata
{
"meta":
[
{
"name": "sum",
"type": "UInt64"
},
{
"name": "avg",
"type": "Float64"
}
],
"data":
{
"sum": ["1", "2", "3", "4"],
"avg": [1, 2, 3, 2]
},
"totals":
{
"sum": "10",
"avg": 2
},
"extremes":
{
"min":
{
"sum": "1",
"avg": 1
},
"max":
{
"sum": "4",
"avg": 3
}
},
"rows": 4,
"statistics":
{
"rows_read": 5,
"bytes_read": 20
}
}
JSONColumnsWithMetadata 3 rows
{
"meta":
[
{
"name": "sum",
"type": "UInt64"
},
{
"name": "avg",
"type": "Float64"
}
],
"data":
{
"sum": ["1", "2", "3", "4"],
"avg": [1, 2, 3, 2]
},
"totals":
{
"sum": "10",
"avg": 2
},
"extremes":
{
"min":
{
"sum": "1",
"avg": 1
},
"max":
{
"sum": "4",
"avg": 3
}
},
"rows": 4,
"statistics":
{
"rows_read": 5,
"bytes_read": 20
}
}
b Nullable(Float64)
a Nullable(Float64)
c Nullable(Float64)
d Nullable(String)
1 3 \N \N
2 2 \N \N
3 1 \N \N
\N \N 1 \N
\N \N 2 \N
\N \N 3 \N
\N \N \N String
OK
3
2
1
c1 Nullable(Float64)
c2 Nullable(Float64)
c3 Nullable(String)
1 1 \N
2 2 \N
3 3 \N
1 \N \N
2 \N \N
3 \N \N
1 2 String
OK
OK

View File

@ -0,0 +1,118 @@
#!/usr/bin/env bash
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
# shellcheck source=../shell_config.sh
. "$CUR_DIR"/../shell_config.sh
USER_FILES_PATH=$(clickhouse-client --query "select _path,_file from file('nonexist.txt', 'CSV', 'val1 char')" 2>&1 | grep Exception | awk '{gsub("/nonexist.txt","",$9); print $9}')
DATA_FILE=$USER_FILES_PATH/data_02293
$CLICKHOUSE_CLIENT -q "drop table if exists test_02293"
$CLICKHOUSE_CLIENT -q "create table test_02293 (a UInt32, b String, c Array(Tuple(Array(UInt32), String))) engine=Memory"
$CLICKHOUSE_CLIENT -q "insert into test_02293 select number, 'String', [(range(number % 3), 'String'), (range(number % 4), 'gnirtS')] from numbers(5) settings max_block_size=2"
echo "JSONColumns"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONColumns"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONColumns" > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONColumns)"
echo "JSONColumnsMonoBlock"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONColumnsMonoBlock"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONColumnsMonoBlock" > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONColumns)"
echo "JSONColumnsMonoBlock 3 rows"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONColumnsMonoBlock settings output_format_json_columns_max_rows_to_buffer=3"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONColumnsMonoBlock settings output_format_json_columns_max_rows_to_buffer=3" > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONColumns)"
echo "JSONCompactColumns"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONCompactColumns"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONCompactColumns" > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONCompactColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONCompactColumns)"
echo "JSONCompactColumnsMonoBlock"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONCompactColumnsMonoBlock"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONCompactColumnsMonoBlock" > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONCompactColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONCompactColumns)"
echo "JSONCompactColumnsMonoBlock 3 rows"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONCompactColumnsMonoBlock settings output_format_json_columns_max_rows_to_buffer=3"
$CLICKHOUSE_CLIENT -q "select * from test_02293 order by a format JSONCompactColumnsMonoBlock settings output_format_json_columns_max_rows_to_buffer=3" > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONCompactColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONCompactColumns)"
echo "JSONColumnsWithMetadata"
$CLICKHOUSE_CLIENT -q "select sum(a) as sum, avg(a) as avg from test_02293 group by a % 4 with totals order by tuple(sum, avg) format JSONColumnsWithMetadata" --extremes=1 | grep -v "elapsed"
echo "JSONColumnsWithMetadata 3 rows"
$CLICKHOUSE_CLIENT -q "select sum(a) as sum, avg(a) as avg from test_02293 group by a % 4 with totals order by tuple(sum, avg) format JSONColumnsWithMetadata settings output_format_json_columns_max_rows_to_buffer=3" --extremes=1 | grep -v "elapsed"
echo '
{
"b": [1, 2, 3],
"a": [3, 2, 1]
}
{
"c": [1, 2, 3]
}
{
}
{
"a": [],
"d": []
}
{
"d": ["String"]
}
' > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONColumns, 'a UInt32, t String')" 2>&1 | grep -F -q 'INCORRECT_DATA' && echo 'OK' || echo 'FAIL'
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONColumns, 'a UInt32, t String') settings input_format_skip_unknown_fields=1"
echo '
[
[1, 2, 3],
[1, 2, 3]
]
[
[1, 2, 3]
]
[
]
[
[],
[]
]
[
[1],
[2],
["String"]
]
' > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONCompactColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONCompactColumns)"
$CLICKHOUSE_CLIENT -q "select * from file(data_02293, JSONCompactColumns, 'a UInt32, t UInt32')" 2>&1 | grep -F -q 'INCORRECT_DATA' && echo 'OK' || echo 'FAIL'
echo '
{
"a": [null, null, null],
"b": [3, 2, 1]
}
{
"a": [1, 2, 3]
}
' > $DATA_FILE
$CLICKHOUSE_CLIENT -q "desc file(data_02293, JSONColumns) settings input_format_max_rows_to_read_for_schema_inference=3" 2>&1 | grep -F -q 'CANNOT_EXTRACT_TABLE_STRUCTURE' && echo 'OK' || echo 'FAIL'