dbms: fixed error; added tests [#METR-19957].

This commit is contained in:
Alexey Milovidov 2016-02-07 12:53:48 +03:00
parent 43c73cf7ee
commit 73994ebb08
5 changed files with 38 additions and 1 deletions

View File

@ -61,7 +61,9 @@ public:
void deserializeTextCSV(Field & field, ReadBuffer & istr, const char delimiter) const override
{
deserializeText(field, istr);
typename NearestFieldType<FieldType>::Type x;
readCSV(x, istr);
field = x;
}
size_t getSizeOfField() const override { return sizeof(FieldType); }

View File

@ -0,0 +1,15 @@
"x","y","z","a","b"
"Hello, ""World""",123,"[1,2,3]",456,"['abc','def']","Newline
here"
"Hello, ""World""",123,"[1,2,3]",456,"['abc','def']","Newline
here"
0,"0","[]","2000-01-01","2000-01-01 00:00:00"
1,"1","[0]","2000-01-02","2000-01-01 00:00:01"
2,"2","[0,1]","2000-01-03","2000-01-01 00:00:02"
3,"3","[0,1,2]","2000-01-04","2000-01-01 00:00:03"
4,"4","[0,1,2,3]","2000-01-05","2000-01-01 00:00:04"
5,"5","[0,1,2,3,4]","2000-01-06","2000-01-01 00:00:05"
6,"6","[0,1,2,3,4,5]","2000-01-07","2000-01-01 00:00:06"
7,"7","[0,1,2,3,4,5,6]","2000-01-08","2000-01-01 00:00:07"
8,"8","[0,1,2,3,4,5,6,7]","2000-01-09","2000-01-01 00:00:08"
9,"9","[0,1,2,3,4,5,6,7,8]","2000-01-10","2000-01-01 00:00:09"

View File

@ -0,0 +1,3 @@
SELECT 'Hello, "World"' AS x, 123 AS y, [1, 2, 3] AS z, (456, ['abc', 'def']) AS a, 'Newline\nhere' AS b FORMAT CSVWithNames;
SELECT 'Hello, "World"' AS x, 123 AS y, [1, 2, 3] AS z, (456, ['abc', 'def']) AS a, 'Newline\nhere' AS b FORMAT CSV;
SELECT number, toString(number), range(number), toDate('2000-01-01') + number, toDateTime('2000-01-01 00:00:00') + number FROM system.numbers LIMIT 10 FORMAT CSV;

View File

@ -0,0 +1,4 @@
Hello, world 123 2016-01-01
Hello, "world" 456 2016-01-02
Hello "world" 789 2016-01-03
Hello\n world 100 2016-01-04

View File

@ -0,0 +1,13 @@
#!/bin/bash
clickhouse-client --query="DROP TABLE IF EXISTS test.csv";
clickhouse-client --query="CREATE TABLE test.csv (s String, n UInt64, d Date) ENGINE = Memory";
echo '"Hello, world", 123, "2016-01-01"
"Hello, ""world""", "456", 2016-01-02
Hello "world", 789 ,2016-01-03
"Hello
world", 100, 2016-01-04' | clickhouse-client --query="INSERT INTO test.csv FORMAT CSV";
clickhouse-client --query="SELECT * FROM test.csv ORDER BY d";
clickhouse-client --query="DROP TABLE test.csv";