add tests for formats with type map

This commit is contained in:
Anton Popov 2020-12-15 21:07:13 +03:00
parent dd09e1d783
commit ba63635251
4 changed files with 33 additions and 7 deletions

View File

@ -33,8 +33,8 @@ JSON
"rows": 2 "rows": 2
} }
JSONEachRow JSONEachRow
{"m":{"k1":10,"k3":30},"m1":{"k2":"2020-06-06"},"m2":{}}
{"m":{"k1":1,"k2":2,"k3":3},"m1":{"k1":"2020-05-05"},"m2":{"k1":[],"k2":[7,8]}} {"m":{"k1":1,"k2":2,"k3":3},"m1":{"k1":"2020-05-05"},"m2":{"k1":[],"k2":[7,8]}}
{"m":{"k1":10,"k3":30},"m1":{"k2":"2020-06-06"},"m2":{}}
CSV CSV
"{'k1':1,'k2':2,'k3':3}","{'k1':'2020-05-05'}","{'k1':[],'k2':[7,8]}" "{'k1':1,'k2':2,'k3':3}","{'k1':'2020-05-05'}","{'k1':[],'k2':[7,8]}"
"{'k1':10,'k3':30}","{'k2':'2020-06-06'}","{}" "{'k1':10,'k3':30}","{'k2':'2020-06-06'}","{}"
@ -42,5 +42,5 @@ TSV
{'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]} {'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]}
{'k1':10,'k3':30} {'k2':'2020-06-06'} {} {'k1':10,'k3':30} {'k2':'2020-06-06'} {}
TSKV TSKV
m={'k1':10,'k3':30} m1={'k2':'2020-06-06'} m2={}
m={'k1':1,'k2':2,'k3':3} m1={'k1':'2020-05-05'} m2={'k1':[],'k2':[7,8]} m={'k1':1,'k2':2,'k3':3} m1={'k1':'2020-05-05'} m2={'k1':[],'k2':[7,8]}
m={'k1':10,'k3':30} m1={'k2':'2020-06-06'} m2={}

View File

@ -8,12 +8,12 @@ INSERT INTO map_formats VALUES(map('k1', 1, 'k2', 2, 'k3', 3), map('k1', toDate(
INSERT INTO map_formats VALUES(map('k1', 10, 'k3', 30), map('k2', toDate('2020-06-06')), map()); INSERT INTO map_formats VALUES(map('k1', 10, 'k3', 30), map('k2', toDate('2020-06-06')), map());
SELECT 'JSON'; SELECT 'JSON';
SELECT * FROM map_formats FORMAT JSON; SELECT * FROM map_formats ORDER BY m['k1'] FORMAT JSON;
SELECT 'JSONEachRow'; SELECT 'JSONEachRow';
SELECT * FROM map_formats FORMAT JSONEachRow; SELECT * FROM map_formats ORDER BY m['k1'] FORMAT JSONEachRow;
SELECT 'CSV'; SELECT 'CSV';
SELECT * FROM map_formats FORMAT CSV; SELECT * FROM map_formats ORDER BY m['k1'] FORMAT CSV;
SELECT 'TSV'; SELECT 'TSV';
SELECT * FROM map_formats FORMAT TSV; SELECT * FROM map_formats ORDER BY m['k1'] FORMAT TSV;
SELECT 'TSKV'; SELECT 'TSKV';
SELECT * FROM map_formats FORMAT TSKV; SELECT * FROM map_formats ORDER BY m['k1'] FORMAT TSKV;

View File

@ -0,0 +1,5 @@
{'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]}
{'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]}
{'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]}
{'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]}
{'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]}

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. "$CURDIR"/../shell_config.sh
$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS map_formats_input"
$CLICKHOUSE_CLIENT -q "CREATE TABLE map_formats_input (m Map(String, UInt32), m1 Map(String, Date), m2 Map(String, Array(UInt32))) ENGINE = Log;" --allow_experimental_map_type 1
$CLICKHOUSE_CLIENT -q "INSERT INTO map_formats_input FORMAT JSONEachRow" <<< '{"m":{"k1":1,"k2":2,"k3":3},"m1":{"k1":"2020-05-05"},"m2":{"k1":[],"k2":[7,8]}}'
$CLICKHOUSE_CLIENT -q "SELECT * FROM map_formats_input"
$CLICKHOUSE_CLIENT -q "TRUNCATE TABLE map_formats_input"
$CLICKHOUSE_CLIENT -q "INSERT INTO map_formats_input FORMAT CSV" <<< "\"{'k1':1,'k2':2,'k3':3}\",\"{'k1':'2020-05-05'}\",\"{'k1':[],'k2':[7,8]}\""
$CLICKHOUSE_CLIENT -q "SELECT * FROM map_formats_input"
$CLICKHOUSE_CLIENT -q "TRUNCATE TABLE map_formats_input"
$CLICKHOUSE_CLIENT -q "INSERT INTO map_formats_input FORMAT TSV" <<< "{'k1':1,'k2':2,'k3':3} {'k1':'2020-05-05'} {'k1':[],'k2':[7,8]}"
$CLICKHOUSE_CLIENT -q "SELECT * FROM map_formats_input"
$CLICKHOUSE_CLIENT -q 'SELECT * FROM map_formats_input FORMAT Native' | $CLICKHOUSE_CLIENT -q "INSERT INTO map_formats_input FORMAT Native"
$CLICKHOUSE_CLIENT -q "SELECT * FROM map_formats_input"