diff options
author | hcpp <hcpp@ydb.tech> | 2022-12-11 22:31:58 +0300 |
---|---|---|
committer | hcpp <hcpp@ydb.tech> | 2022-12-11 22:31:58 +0300 |
commit | db0f03b45a4ee28bf9645dac2999a89c3bc61c46 (patch) | |
tree | 610b6fda9db6580070a9b20749ef9551e07149f1 | |
parent | e25f28e14731646366f266d92cc891eb1eb85fcc (diff) | |
download | ydb-db0f03b45a4ee28bf9645dac2999a89c3bc61c46.tar.gz |
default parsers has been disabled
-rw-r--r-- | ydb/library/yql/udfs/common/clickhouse/client/src/IO/ReadHelpers.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/ydb/library/yql/udfs/common/clickhouse/client/src/IO/ReadHelpers.cpp b/ydb/library/yql/udfs/common/clickhouse/client/src/IO/ReadHelpers.cpp index 879b6f0dfe1..ffe2530691f 100644 --- a/ydb/library/yql/udfs/common/clickhouse/client/src/IO/ReadHelpers.cpp +++ b/ydb/library/yql/udfs/common/clickhouse/client/src/IO/ReadHelpers.cpp @@ -1182,22 +1182,29 @@ void readDateTimeTextISO(time_t & x, ReadBuffer & istr) { throw yexception() << "error in datetime parsing. Input data: " << istr.position(); } -void readDateTimeTextFormat(time_t & x, ReadBuffer & istr, const String& format) +char* readDateTimeTextFormat(time_t & x, char* str, const String& format) { struct tm input_tm; memset(&input_tm, 0, sizeof(tm)); input_tm.tm_mday = 1; - auto ptr = strptime(istr.position(), format.c_str(), &input_tm); + auto ptr = strptime(str, format.c_str(), &input_tm); if (ptr == nullptr) { - ythrow yexception() << "Can't parse date " << istr.position() << " in " << format << " format"; + ythrow yexception() << "Can't parse date " << str << " in " << format << " format"; } - istr.position() = ptr; x = TimeGM(&input_tm); + return ptr; +} + +void readDateTimeTextFormat(time_t & x, ReadBuffer & istr, const String& format) +{ + istr.position() = readDateTimeTextFormat(x, istr.position(), format); } void readDateTimeTextPOSIX(time_t & x, ReadBuffer & istr) { - readDateTimeTextFormat(x, istr, "%Y-%m-%d %H:%M:%S"); + char prefix[20] = {}; + istr.readStrict(prefix, 19); + readDateTimeTextFormat(x, prefix, "%Y-%m-%d %H:%M:%S"); } void readTimestampTextISO(DateTime64 & x, ReadBuffer & istr) { @@ -1214,22 +1221,29 @@ void readTimestampTextISO(DateTime64 & x, ReadBuffer & istr) { throw yexception() << "error in datetime parsing. Input data: " << istr.position(); } -void readTimestampTextFormat(DateTime64 & x, ReadBuffer & istr, const String& format) +char* readTimestampTextFormat(DateTime64 & x, char* str, const String& format) { struct tm input_tm; memset(&input_tm, 0, sizeof(tm)); input_tm.tm_mday = 1; - auto ptr = strptime(istr.position(), format.c_str(), &input_tm); + auto ptr = strptime(str, format.c_str(), &input_tm); if (ptr == nullptr) { - ythrow yexception() << "Can't parse date " << istr.position() << " in " << format << " format"; + ythrow yexception() << "Can't parse date " << str << " in " << format << " format"; } - istr.position() = ptr; x = TimeGM(&input_tm) * 1000000; + return ptr; +} + +void readTimestampTextFormat(DateTime64 & x, ReadBuffer & istr, const String& format) +{ + istr.position() = readTimestampTextFormat(x, istr.position(), format); } void readTimestampTextPOSIX(DateTime64 & x, ReadBuffer & istr) { - readTimestampTextFormat(x, istr, "%Y-%m-%d %H:%M:%S"); + char prefix[20] = {}; + istr.readStrict(prefix, 19); + readTimestampTextFormat(x, prefix, "%Y-%m-%d %H:%M:%S"); } } |