From 0a83cfccdef616bb0f2627e79ca2091f3de67a94 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Fri, 30 Dec 2016 09:23:30 +0300 Subject: [PATCH] NULLs: Test also output formats [#METR-19266]. --- .../0_stateless/00407_parsing_nulls.reference | 23 +++++++++++++++ .../0_stateless/00407_parsing_nulls.sh | 28 +++++++++++++++---- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/dbms/tests/queries/0_stateless/00407_parsing_nulls.reference b/dbms/tests/queries/0_stateless/00407_parsing_nulls.reference index fbd206f4c00..359f5b19130 100644 --- a/dbms/tests/queries/0_stateless/00407_parsing_nulls.reference +++ b/dbms/tests/queries/0_stateless/00407_parsing_nulls.reference @@ -9,3 +9,26 @@ N \N 2000-01-01 00:00:00 \N 111 2000-01-01 00:00:00 \N \N ab \N \N +" Hello",123,\N +\N,0,"2000-01-01 00:00:00" +"Hello",123,\N +\N,0,"2000-01-01 00:00:00" +"\Hello",123,\N +"\N",0,"2000-01-01 00:00:00" +\N,123,\N +"N",\N,"2000-01-01 00:00:00" +\N,111,"2000-01-01 00:00:00" +"",\N,\N +"ab",\N,\N +{"s":"\tHello","x":"123","t":null} +{"s":null,"x":"0","t":"2000-01-01 00:00:00"} +{"s":"Hello","x":"123","t":null} +{"s":null,"x":"0","t":"2000-01-01 00:00:00"} +{"s":"\\Hello","x":"123","t":null} +{"s":"\\N","x":"0","t":"2000-01-01 00:00:00"} +{"s":null,"x":"123","t":null} +{"s":"N","x":null,"t":"2000-01-01 00:00:00"} +{"s":null,"x":"111","t":"2000-01-01 00:00:00"} +{"s":"","x":null,"t":null} +{"s":"ab","x":null,"t":null} +('\tHello',123,NULL),(NULL,0,'2000-01-01 00:00:00')('Hello',123,NULL),(NULL,0,'2000-01-01 00:00:00')('\\Hello',123,NULL),('\\N',0,'2000-01-01 00:00:00')(NULL,123,NULL),('N',NULL,'2000-01-01 00:00:00')(NULL,111,'2000-01-01 00:00:00'),('',NULL,NULL),('ab',NULL,NULL) \ No newline at end of file diff --git a/dbms/tests/queries/0_stateless/00407_parsing_nulls.sh b/dbms/tests/queries/0_stateless/00407_parsing_nulls.sh index a044db5a1a3..0d25bb81bac 100755 --- a/dbms/tests/queries/0_stateless/00407_parsing_nulls.sh +++ b/dbms/tests/queries/0_stateless/00407_parsing_nulls.sh @@ -1,8 +1,26 @@ #!/usr/bin/env bash set -e -echo -ne '\\tHello\t123\t\\N\n\\N\t\t2000-01-01 00:00:00\n' | clickhouse-local --format=TabSeparated --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null -echo -ne 'Hello,123,\\N\n\\N,0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null -echo -ne '"\\Hello",123,\\N\n"\\N",0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null -echo -ne '{"s" : null, "x" : 123}, {"s" : "\N", "t":"2000-01-01 00:00:00"}' | clickhouse-local --input-format=JSONEachRow --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null -echo "(NULL, 111, '2000-01-01 00:00:00'), ('\N', NULL, NULL), ('a\Nb', NULL, NULL)" | clickhouse-local --input-format=Values --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '\\tHello\t123\t\\N\n\\N\t\t2000-01-01 00:00:00\n' | clickhouse-local --input-format=TabSeparated --output-format=TabSeparated --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne 'Hello,123,\\N\n\\N,0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=TabSeparated --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '"\\Hello",123,\\N\n"\\N",0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=TabSeparated --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '{"s" : null, "x" : 123}, {"s" : "\N", "t":"2000-01-01 00:00:00"}' | clickhouse-local --input-format=JSONEachRow --output-format=TabSeparated --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo "(NULL, 111, '2000-01-01 00:00:00'), ('\N', NULL, NULL), ('a\Nb', NULL, NULL)" | clickhouse-local --input-format=Values --output-format=TabSeparated --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null + +echo -ne '\\tHello\t123\t\\N\n\\N\t\t2000-01-01 00:00:00\n' | clickhouse-local --input-format=TabSeparated --output-format=CSV --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne 'Hello,123,\\N\n\\N,0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=CSV --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '"\\Hello",123,\\N\n"\\N",0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=CSV --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '{"s" : null, "x" : 123}, {"s" : "\N", "t":"2000-01-01 00:00:00"}' | clickhouse-local --input-format=JSONEachRow --output-format=CSV --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo "(NULL, 111, '2000-01-01 00:00:00'), ('\N', NULL, NULL), ('a\Nb', NULL, NULL)" | clickhouse-local --input-format=Values --output-format=CSV --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null + +echo -ne '\\tHello\t123\t\\N\n\\N\t\t2000-01-01 00:00:00\n' | clickhouse-local --input-format=TabSeparated --output-format=JSONEachRow --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne 'Hello,123,\\N\n\\N,0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=JSONEachRow --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '"\\Hello",123,\\N\n"\\N",0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=JSONEachRow --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '{"s" : null, "x" : 123}, {"s" : "\N", "t":"2000-01-01 00:00:00"}' | clickhouse-local --input-format=JSONEachRow --output-format=JSONEachRow --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo "(NULL, 111, '2000-01-01 00:00:00'), ('\N', NULL, NULL), ('a\Nb', NULL, NULL)" | clickhouse-local --input-format=Values --output-format=JSONEachRow --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null + +echo -ne '\\tHello\t123\t\\N\n\\N\t\t2000-01-01 00:00:00\n' | clickhouse-local --input-format=TabSeparated --output-format=Values --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne 'Hello,123,\\N\n\\N,0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=Values --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '"\\Hello",123,\\N\n"\\N",0,"2000-01-01 00:00:00"' | clickhouse-local --input-format=CSV --output-format=Values --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo -ne '{"s" : null, "x" : 123}, {"s" : "\N", "t":"2000-01-01 00:00:00"}' | clickhouse-local --input-format=JSONEachRow --output-format=Values --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null +echo "(NULL, 111, '2000-01-01 00:00:00'), ('\N', NULL, NULL), ('a\Nb', NULL, NULL)" | clickhouse-local --input-format=Values --output-format=Values --structure='s Nullable(String), x Nullable(UInt64), t Nullable(DateTime)' --query="SELECT * FROM table" 2>/dev/null