From 446df4342eab6f3a0e3466adb772dae51a15fcad Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Fri, 14 Sep 2018 09:12:56 +0000 Subject: [PATCH] Testing of JSONEachRow input of Nested data The new test demonstrates current handling of flat JSON data corresponding to nested columns. --- ...00715_json_each_row_input_nested.reference | 5 +++++ .../00715_json_each_row_input_nested.sh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.reference create mode 100755 dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.sh diff --git a/dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.reference b/dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.reference new file mode 100644 index 00000000000..73f7522fb37 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.reference @@ -0,0 +1,5 @@ +1 ok ['abc','def'] [1,23] +0 [] [] +0 [] [45,67,8] +1 ok ['dog','cat','pig'] [3,3,3] +1 ok ['zero','negative one'] [0,-1] diff --git a/dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.sh b/dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.sh new file mode 100755 index 00000000000..4d7514bdf4c --- /dev/null +++ b/dbms/tests/queries/0_stateless/00715_json_each_row_input_nested.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -e + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test.json_each_row_nested" +$CLICKHOUSE_CLIENT -q "CREATE TABLE test.json_each_row_nested (d1 UInt8, d2 String, n Nested (s String, i Int32) ) ENGINE = Memory" + +echo '{"d1" : 1, "d2" : "ok", "n.s" : ["abc", "def"], "n.i" : [1, 23]} +{ } +{"t1" : 0, "n.t2":true,"n.i":[45, 67, 8], "t4":null,"t5":[],"t6":"trash" } +{"d2":"ok","n.s":["dog", "cat", "pig"], "n.x":[["1","2"]], "d1":"1", "n.i":[3, 3, 3]} +{"t0" : -0.1, "n.s" : ["zero","negative one"], "a.b" : 0, "n.i" : [0, -1], "d2" : "ok", "d1" : 1}' \ +| $CLICKHOUSE_CLIENT --input_format_skip_unknown_fields=1 -q "INSERT INTO test.json_each_row_nested FORMAT JSONEachRow" + +$CLICKHOUSE_CLIENT --max_threads=1 -q "SELECT * FROM test.json_each_row_nested" +$CLICKHOUSE_CLIENT -q "DROP TABLE IF EXISTS test.json_each_row_nested"