diff --git a/dbms/tests/queries/0_stateless/00937_template_output_format.reference b/dbms/tests/queries/0_stateless/00937_template_output_format.reference new file mode 100644 index 00000000000..c4cfb4ed3a4 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00937_template_output_format.reference @@ -0,0 +1,16 @@ +{prefix} +n: "123", s1: qwe,rty, s2: 'as"df\'gh', s3: "", s4: "zx +cv bn m", d: 2016-01-01, n: 123 ; +n: "456", s1: as"df\'gh, s2: '', s3: "zx\ncv\tbn m", s4: "qwe,rty", d: 2016-01-02, n: 456 ; +n: "9876543210", s1: , s2: 'zx\ncv\tbn m', s3: "qwe,rty", s4: "as""df'gh", d: 2016-01-03, n: 9876543210 ; +n: "789", s1: zx\ncv\tbn m, s2: 'qwe,rty', s3: "as\"df'gh", s4: "", d: 2016-01-04, n: 789 +------ +n: "0", s1: , s2: '', s3: "", s4: "", d: 0000-00-00, n: 0 +------ +n: "123", s1: , s2: '', s3: "", s4: "", d: 2016-01-01, n: 123 +------ +n: "9876543210", s1: zx\ncv\tbn m, s2: 'zx\ncv\tbn m', s3: "zx\ncv\tbn m", s4: "zx +cv bn m", d: 2016-01-04, n: 9876543210 +4 rows +before limit 4 +read 4 $ suffix $ \ No newline at end of file diff --git a/dbms/tests/queries/0_stateless/00937_template_output_format.sql b/dbms/tests/queries/0_stateless/00937_template_output_format.sql new file mode 100644 index 00000000000..9aed990149a --- /dev/null +++ b/dbms/tests/queries/0_stateless/00937_template_output_format.sql @@ -0,0 +1,12 @@ +DROP TABLE IF EXISTS test.template; +CREATE TABLE test.template (s1 String, s2 String, s3 String, s4 String, n UInt64, d Date) ENGINE = Memory; +INSERT INTO test.template VALUES +('qwe,rty', 'as"df''gh', '', 'zx\ncv\tbn m', 123, '2016-01-01'),('as"df''gh', '', 'zx\ncv\tbn m', 'qwe,rty', 456, '2016-01-02'),('', 'zx\ncv\tbn m', 'qwe,rty', 'as"df''gh', 9876543210, '2016-01-03'),('zx\ncv\tbn m', 'qwe,rty', 'as"df''gh', '', 789, '2016-01-04'); + +SELECT * FROM test.template WITH TOTALS LIMIT 4 FORMAT Template SETTINGS +extremes = 1, +format_schema = '{prefix} \n${data}\n------\n${totals:}\n------\n${min}\n------\n${max}\n${rows:} rows\nbefore limit ${rows_before_limit:XML}\nread ${rows_read} $$ suffix $$', +format_schema_rows = 'n:\t${n:JSON}, s1:\t${s1:Escaped}, s2:\t${s2:Quoted}, s3:\t${s3:JSON}, s4:\t${s4:CSV}, d:\t${d}, n:\t${n:Raw}\t', +format_schema_rows_between_delimiter = ';\n'; + +DROP TABLE test.template; \ No newline at end of file diff --git a/dbms/tests/queries/0_stateless/00938_template_input_format.reference b/dbms/tests/queries/0_stateless/00938_template_input_format.reference new file mode 100644 index 00000000000..3947822de3f --- /dev/null +++ b/dbms/tests/queries/0_stateless/00938_template_input_format.reference @@ -0,0 +1,8 @@ +"qwe,rty","as""df'gh","","zx +cv bn m",123,"2016-01-01" +"as""df'gh","","zx +cv bn m","qwe,rty",456,"2016-01-02" +"zx +cv bn m","qwe,rty","as""df'gh","",789,"2016-01-04" +"","zx +cv bn m","qwe,rty","as""df'gh",9876543210,"2016-01-03" diff --git a/dbms/tests/queries/0_stateless/00938_template_input_format.sh b/dbms/tests/queries/0_stateless/00938_template_input_format.sh new file mode 100755 index 00000000000..c397c901f22 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00938_template_input_format.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +. $CURDIR/../shell_config.sh + +$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS test.template"; +$CLICKHOUSE_CLIENT --query="CREATE TABLE test.template (s1 String, s2 String, s3 String, s4 String, n UInt64, d Date) ENGINE = Memory"; + +echo "{prefix} +n: 123, s1: qwe,rty , s2: 'as\"df\\'gh', s3: \"\", s4: \"zx +cv bn m\", d: 2016-01-01 ; +n: 456, s1: as\"df\\'gh , s2: '', s3: \"zx\\ncv\\tbn m\", s4: \"qwe,rty\", d: 2016-01-02 ; +n: 9876543210, s1: , s2: 'zx\\ncv\\tbn m', s3: \"qwe,rty\", s4: \"as\"\"df'gh\", d: 2016-01-03 ; +n: 789, s1: zx\\ncv\\tbn m , s2: 'qwe,rty', s3: \"as\\\"df'gh\", s4: \"\", d: 2016-01-04 + $ suffix $" | $CLICKHOUSE_CLIENT --query="INSERT INTO test.template FORMAT Template SETTINGS format_schema = '{prefix} \n\${data}\n \$\$ suffix \$\$\n', format_schema_rows = 'n:\t\${n}, s1:\t\${s1:Escaped}\t, s2:\t\${s2:Quoted}, s3:\t\${s3:JSON}, s4:\t\${s4:CSV}, d:\t\${d}\t', format_schema_rows_between_delimiter = ';\n'"; + +$CLICKHOUSE_CLIENT --query="SELECT * FROM test.template ORDER BY n FORMAT CSV"; +$CLICKHOUSE_CLIENT --query="DROP TABLE test.template";