mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 16:42:05 +00:00
Add tests
This commit is contained in:
parent
86fa185bb6
commit
c25a99aaf5
47
tests/queries/0_stateless/01446_JSONStringsEachRow.reference
Normal file
47
tests/queries/0_stateless/01446_JSONStringsEachRow.reference
Normal file
@ -0,0 +1,47 @@
|
||||
1
|
||||
["1", "a"]
|
||||
["2", "b"]
|
||||
["3", "c"]
|
||||
2
|
||||
["a", "1"]
|
||||
["b", "1"]
|
||||
["c", "1"]
|
||||
3
|
||||
["value", "name"]
|
||||
["UInt8", "String"]
|
||||
["1", "a"]
|
||||
["2", "b"]
|
||||
["3", "c"]
|
||||
4
|
||||
["name", "c"]
|
||||
["String", "UInt64"]
|
||||
["a", "1"]
|
||||
["b", "1"]
|
||||
["c", "1"]
|
||||
|
||||
["", "3"]
|
||||
5
|
||||
["first", "1", "2", "0"]
|
||||
["second", "2", "0", "6"]
|
||||
6
|
||||
["first", "1", "2", "0"]
|
||||
["second", "2", "0", "6"]
|
||||
7
|
||||
["16", "[15,16,17]", "['first','second','third']"]
|
||||
8
|
||||
["first", "1", "2", "0"]
|
||||
["second", "2", "0", "6"]
|
||||
9
|
||||
["first", "1", "2", "0"]
|
||||
["second", "2", "0", "6"]
|
||||
10
|
||||
["first", "1", "16", "8"]
|
||||
["second", "2", "32", "8"]
|
||||
11
|
||||
["v1", "v2", "v3", "v4"]
|
||||
["String", "UInt8", "UInt16", "UInt8"]
|
||||
["", "2", "3", "1"]
|
||||
12
|
||||
["v1", "n.id", "n.name"]
|
||||
["UInt8", "Array(UInt8)", "Array(String)"]
|
||||
["16", "[15,16,17]", "['first','second','third']"]
|
63
tests/queries/0_stateless/01446_JSONStringsEachRow.sql
Normal file
63
tests/queries/0_stateless/01446_JSONStringsEachRow.sql
Normal file
@ -0,0 +1,63 @@
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
DROP TABLE IF EXISTS test_table_2;
|
||||
SELECT 1;
|
||||
/* Check JSONStringsEachRow Output */
|
||||
CREATE TABLE test_table (value UInt8, name String) ENGINE = MergeTree() ORDER BY value;
|
||||
INSERT INTO test_table VALUES (1, 'a'), (2, 'b'), (3, 'c');
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRow;
|
||||
SELECT 2;
|
||||
/* Check Totals */
|
||||
SELECT name, count() AS c FROM test_table GROUP BY name WITH TOTALS ORDER BY name FORMAT JSONStringsEachRow;
|
||||
SELECT 3;
|
||||
/* Check JSONStringsEachRowWithNamesAndTypes Output */
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRowWithNamesAndTypes;
|
||||
SELECT 4;
|
||||
/* Check Totals */
|
||||
SELECT name, count() AS c FROM test_table GROUP BY name WITH TOTALS ORDER BY name FORMAT JSONStringsEachRowWithNamesAndTypes;
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
SELECT 5;
|
||||
/* Check JSONStringsEachRow Input */
|
||||
CREATE TABLE test_table (v1 String, v2 UInt8, v3 DEFAULT v2 * 16, v4 UInt8 DEFAULT 8) ENGINE = MergeTree() ORDER BY v2;
|
||||
INSERT INTO test_table FORMAT JSONStringsEachRow ["first", "1", "2", "NULL"] ["second", "2", "null", "6"];
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRow;
|
||||
TRUNCATE TABLE test_table;
|
||||
SELECT 6;
|
||||
/* Check input_format_null_as_default = 1 */
|
||||
SET input_format_null_as_default = 1;
|
||||
INSERT INTO test_table FORMAT JSONStringsEachRow ["first", "1", "2", "ᴺᵁᴸᴸ"] ["second", "2", "null", "6"];
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRow;
|
||||
TRUNCATE TABLE test_table;
|
||||
SELECT 7;
|
||||
/* Check Nested */
|
||||
CREATE TABLE test_table_2 (v1 UInt8, n Nested(id UInt8, name String)) ENGINE = MergeTree() ORDER BY v1;
|
||||
INSERT INTO test_table_2 FORMAT JSONStringsEachRow ["16", "[15, 16, 17]", "['first', 'second', 'third']"];
|
||||
SELECT * FROM test_table_2 FORMAT JSONStringsEachRow;
|
||||
TRUNCATE TABLE test_table_2;
|
||||
SELECT 8;
|
||||
/* Check JSONStringsEachRowWithNamesAndTypes Output */
|
||||
SET input_format_null_as_default = 0;
|
||||
INSERT INTO test_table FORMAT JSONStringsEachRowWithNamesAndTypes ["v1", "v2", "v3", "v4"]["String","UInt8","UInt16","UInt8"]["first", "1", "2", "null"]["second", "2", "null", "6"];
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRow;
|
||||
TRUNCATE TABLE test_table;
|
||||
SELECT 9;
|
||||
/* Check input_format_null_as_default = 1 */
|
||||
SET input_format_null_as_default = 1;
|
||||
INSERT INTO test_table FORMAT JSONStringsEachRowWithNamesAndTypes ["v1", "v2", "v3", "v4"]["String","UInt8","UInt16","UInt8"]["first", "1", "2", "null"] ["second", "2", "null", "6"];
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRow;
|
||||
SELECT 10;
|
||||
/* Check Header */
|
||||
TRUNCATE TABLE test_table;
|
||||
SET input_format_skip_unknown_fields = 1;
|
||||
INSERT INTO test_table FORMAT JSONStringsEachRowWithNamesAndTypes ["v1", "v2", "invalid_column"]["String", "UInt8", "UInt8"]["first", "1", "32"]["second", "2", "64"];
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRow;
|
||||
SELECT 11;
|
||||
TRUNCATE TABLE test_table;
|
||||
INSERT INTO test_table FORMAT JSONStringsEachRowWithNamesAndTypes ["v4", "v2", "v3"]["UInt8", "UInt8", "UInt16"]["1", "2", "3"]
|
||||
SELECT * FROM test_table FORMAT JSONStringsEachRowWithNamesAndTypes;
|
||||
SELECT 12;
|
||||
/* Check Nested */
|
||||
INSERT INTO test_table_2 FORMAT JSONStringsEachRowWithNamesAndTypes ["v1", "n.id", "n.name"]["UInt8", "Array(UInt8)", "Array(String)"]["16", "[15, 16, 17]", "['first', 'second', 'third']"];
|
||||
SELECT * FROM test_table_2 FORMAT JSONStringsEachRowWithNamesAndTypes;
|
||||
|
||||
DROP TABLE IF EXISTS test_table;
|
||||
DROP TABLE IF EXISTS test_table_2;
|
43
tests/queries/0_stateless/01447_JSONStrings.reference
Normal file
43
tests/queries/0_stateless/01447_JSONStrings.reference
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"meta":
|
||||
[
|
||||
{
|
||||
"name": "1",
|
||||
"type": "UInt8"
|
||||
},
|
||||
{
|
||||
"name": "'a'",
|
||||
"type": "String"
|
||||
},
|
||||
{
|
||||
"name": "[1, 2, 3]",
|
||||
"type": "Array(UInt8)"
|
||||
},
|
||||
{
|
||||
"name": "tuple(1, 'a')",
|
||||
"type": "Tuple(UInt8, String)"
|
||||
},
|
||||
{
|
||||
"name": "NULL",
|
||||
"type": "Nullable(Nothing)"
|
||||
},
|
||||
{
|
||||
"name": "nan",
|
||||
"type": "Float64"
|
||||
}
|
||||
],
|
||||
|
||||
"data":
|
||||
[
|
||||
["1", "a", "[1,2,3]", "(1,'a')", "ᴺᵁᴸᴸ", "nan"]
|
||||
],
|
||||
|
||||
"rows": 1,
|
||||
|
||||
"statistics":
|
||||
{
|
||||
"elapsed": 0.00068988,
|
||||
"rows_read": 1,
|
||||
"bytes_read": 1
|
||||
}
|
||||
}
|
8
tests/queries/0_stateless/01447_JSONStrings.sql
Normal file
8
tests/queries/0_stateless/01447_JSONStrings.sql
Normal file
@ -0,0 +1,8 @@
|
||||
SELECT
|
||||
1,
|
||||
'a',
|
||||
[1, 2, 3],
|
||||
(1, 'a'),
|
||||
null,
|
||||
nan
|
||||
FORMAT JSONStrings;
|
Loading…
Reference in New Issue
Block a user