Allow trailing comma in the Values format

This commit is contained in:
Alexey Milovidov 2024-05-15 06:01:49 +02:00
parent 17fc2936ce
commit f88d294dd0
3 changed files with 15 additions and 0 deletions

View File

@ -572,9 +572,16 @@ bool ValuesBlockInputFormat::checkDelimiterAfterValue(size_t column_idx)
skipWhitespaceIfAny(*buf);
if (likely(column_idx + 1 != num_columns))
{
return checkChar(',', *buf);
}
else
{
/// Optional trailing comma.
if (checkChar(',', *buf))
skipWhitespaceIfAny(*buf);
return checkChar(')', *buf);
}
}
bool ValuesBlockInputFormat::shouldDeduceNewTemplate(size_t column_idx)

View File

@ -0,0 +1,3 @@
1 2 3
4 5 6
7 8 9

View File

@ -0,0 +1,5 @@
CREATE TEMPORARY TABLE test (a UInt8, b UInt8, c UInt8);
INSERT INTO test (a, b, c) VALUES (1, 2, 3, );
INSERT INTO test (a, b, c) VALUES (4, 5, 6,);
INSERT INTO test (a, b, c) VALUES (7, 8, 9);
SELECT * FROM test ORDER BY a;