dbms: CSV format: added support for excessive delimiter at end of row [#METR-19957].

This commit is contained in:
Alexey Milovidov 2016-02-07 13:23:02 +03:00
parent 73994ebb08
commit dc982b1493
2 changed files with 10 additions and 2 deletions

View File

@ -86,6 +86,14 @@ bool CSVRowInputStream::read(Row & row)
if (istr.eof())
break;
/// поддерживаем лишний разделитель на конце строки
if (*istr.position() == delimiter)
{
++istr.position();
if (istr.eof())
break;
}
/// \n (Unix) или \r\n (DOS/Windows) или \n\r (Mac OS Classic)
if (*istr.position() == '\n')

View File

@ -4,10 +4,10 @@ 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""", "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";
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";