From 087a0e939bdddbf8c2d5f8eda84f484a45f03486 Mon Sep 17 00:00:00 2001 From: zvonand Date: Tue, 4 Oct 2022 01:38:54 +0300 Subject: [PATCH] fix date csv parsing --- .../Serializations/SerializationDate.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/DataTypes/Serializations/SerializationDate.cpp b/src/DataTypes/Serializations/SerializationDate.cpp index 60db191a9dc..3b78da97271 100644 --- a/src/DataTypes/Serializations/SerializationDate.cpp +++ b/src/DataTypes/Serializations/SerializationDate.cpp @@ -76,9 +76,22 @@ void SerializationDate::serializeTextCSV(const IColumn & column, size_t row_num, void SerializationDate::deserializeTextCSV(IColumn & column, ReadBuffer & istr, const FormatSettings &) const { - LocalDate value; - readCSV(value, istr); - assert_cast(column).getData().push_back(value.getDayNum()); + DayNum x; + + if (istr.eof()) + throwReadAfterEOF(); + + char maybe_quote = *istr.position(); + + if (maybe_quote == '\'' || maybe_quote == '\"') + ++istr.position(); + + readDateText(x, istr); + + if (maybe_quote == '\'' || maybe_quote == '\"') + assertChar(maybe_quote, istr); + + assert_cast(column).getData().push_back(x); } }