diff --git a/dbms/src/DataTypes/DataTypeArray.cpp b/dbms/src/DataTypes/DataTypeArray.cpp index 5570e8cf069..826e830bad2 100644 --- a/dbms/src/DataTypes/DataTypeArray.cpp +++ b/dbms/src/DataTypes/DataTypeArray.cpp @@ -165,8 +165,15 @@ void DataTypeArray::deserializeText(Field & field, ReadBuffer & istr) const first = false; + skipWhitespaceIfAny(istr); + + if (*istr.position() == ']') + break; + arr.push_back(Field()); nested->deserializeTextQuoted(arr.back(), istr); + + skipWhitespaceIfAny(istr); } assertString("]", istr); diff --git a/dbms/tests/queries/0_stateless/00117_parsing_arrays.reference b/dbms/tests/queries/0_stateless/00117_parsing_arrays.reference new file mode 100644 index 00000000000..6983649366a --- /dev/null +++ b/dbms/tests/queries/0_stateless/00117_parsing_arrays.reference @@ -0,0 +1,11 @@ +[] [] [] +[] [] [] +[] [] [] +[] [] [[]] +[] [] [[],[]] +[] [] [['2015-01-01','2015-01-02'],['2015-01-03','2015-01-04']] +[] ['Hello','World'] [] +[1,2] [] [] +[3,4] [] [] +[5,6] [] [] +[7,8] [] [] diff --git a/dbms/tests/queries/0_stateless/00117_parsing_arrays.sql b/dbms/tests/queries/0_stateless/00117_parsing_arrays.sql new file mode 100644 index 00000000000..408c129cd31 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00117_parsing_arrays.sql @@ -0,0 +1,10 @@ +DROP TABLE IF EXISTS test.null; +CREATE TABLE test.null (a Array(UInt64), b Array(String), c Array(Array(Date))) ENGINE = Memory; + +INSERT INTO test.null (a) VALUES ([1,2]), ([3, 4]), ([ 5 ,6]), ([ 7 , 8 ]), ([]), ([ ]); +INSERT INTO test.null (b) VALUES ([ 'Hello' , 'World' ]); +INSERT INTO test.null (c) VALUES ([ ]), ([ [ ] ]), ([[],[]]), ([['2015-01-01', '2015-01-02'], ['2015-01-03', '2015-01-04']]); + +SELECT a, b, c FROM test.null ORDER BY a, b, c; + +DROP TABLE test.null; \ No newline at end of file