From 5333258e7e8f3569b3d3b31a51462652d9c902d2 Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Fri, 1 Nov 2019 10:48:15 +0800 Subject: [PATCH] Complement to tuple parser --- dbms/src/DataTypes/DataTypeTuple.cpp | 7 +++++++ dbms/tests/queries/0_stateless/01021_tuple_parser.sql | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/dbms/src/DataTypes/DataTypeTuple.cpp b/dbms/src/DataTypes/DataTypeTuple.cpp index bd0e7e6ea3a..c9396b7f673 100644 --- a/dbms/src/DataTypes/DataTypeTuple.cpp +++ b/dbms/src/DataTypes/DataTypeTuple.cpp @@ -188,6 +188,13 @@ void DataTypeTuple::deserializeText(IColumn & column, ReadBuffer & istr, const F } }); + // Special format for one element tuple (1,) + if (1 == elems.size()) + { + skipWhitespaceIfAny(istr); + // Allow both (1) and (1,) + checkChar(',', istr); + } skipWhitespaceIfAny(istr); assertChar(')', istr); } diff --git a/dbms/tests/queries/0_stateless/01021_tuple_parser.sql b/dbms/tests/queries/0_stateless/01021_tuple_parser.sql index e00ec799440..d0c837fae83 100644 --- a/dbms/tests/queries/0_stateless/01021_tuple_parser.sql +++ b/dbms/tests/queries/0_stateless/01021_tuple_parser.sql @@ -2,4 +2,12 @@ SELECT toTypeName((1,)), (1,); SET enable_debug_queries = 1; -ANALYZE SELECT (1,) +ANALYZE SELECT (1,); + +DROP TABLE IF EXISTS tuple_values; + +CREATE TABLE tuple_values (t Tuple(int)) ENGINE = Memory; + +INSERT INTO tuple_values VALUES ((1)), ((2,)); + +DROP TABLE tuple_values;