From b1406f4631c91e3aa71304a4969cfc0f491174e9 Mon Sep 17 00:00:00 2001 From: Michael Kolupaev Date: Wed, 26 Dec 2012 14:40:38 +0000 Subject: [PATCH] clickhouse: fix for prev. rev. [#CONV-6318]. --- dbms/include/DB/Functions/FunctionsReinterpret.h | 2 +- dbms/src/Server/OLAPQueryConverter.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dbms/include/DB/Functions/FunctionsReinterpret.h b/dbms/include/DB/Functions/FunctionsReinterpret.h index a35491f01a1..ce7db802359 100644 --- a/dbms/include/DB/Functions/FunctionsReinterpret.h +++ b/dbms/include/DB/Functions/FunctionsReinterpret.h @@ -39,7 +39,7 @@ public: ErrorCodes::NUMBER_OF_ARGUMENTS_DOESNT_MATCH); const IDataType * type = &*arguments[0]; - if (type->isNumeric() && + if (!type->isNumeric() && !dynamic_cast(type) && !dynamic_cast(type)) throw Exception("Cannot reinterpret " + type->getName() + " as String", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT); diff --git a/dbms/src/Server/OLAPQueryConverter.cpp b/dbms/src/Server/OLAPQueryConverter.cpp index 5dbf361e5bb..3c983963d06 100644 --- a/dbms/src/Server/OLAPQueryConverter.cpp +++ b/dbms/src/Server/OLAPQueryConverter.cpp @@ -518,8 +518,8 @@ void QueryConverter::fillFormattedAttributeMap() M("WindowClientArea", "concat(concat(toString(WindowClientWidth),'x'),toString(WindowClientHeight))") - M("UserAgent", "concat(concat(concat(toString(UserAgent), ' '), toString(UserAgentMajor)), UserAgentMinor == 0 ? '' : concat('.', reinterpretAsString(UserAgentMinor)))") - M("UserAgentVersion", "concat(toString(UserAgentMajor), UserAgentMinor == 0 ? '' : concat('.', reinterpretAsString(UserAgentMinor)))") + M("UserAgent", "concat(concat(concat(toString(UserAgent), ' '), toString(UserAgentMajor)), UserAgentMinor == 0 ? '' : concat('.', trimRight(reinterpretAsString(UserAgentMinor))))") + M("UserAgentVersion", "concat(toString(UserAgentMajor), UserAgentMinor == 0 ? '' : concat('.', trimRight(reinterpretAsString(UserAgentMinor))))") M("UserAgentMajor", "concat(concat(toString(UserAgent), ' '), toString(UserAgentMajor))") #undef M } @@ -530,7 +530,7 @@ void QueryConverter::fillFormattingAggregatedAttributeMap() std::string todate = "toDate(toDateTime(%s))"; std::string todatetime = "toDateTime(%s)"; std::string cuttime = "substring(toString(toDateTime(%s)), 12, 8)"; - std::string tostring = "reinterpretAsString(%s)"; + std::string tostring = "trimRight(reinterpretAsString(%s))"; M("VisitStartDateTime", todatetime) M("VisitStartDate", todate) @@ -569,8 +569,8 @@ void QueryConverter::fillFormattingAggregatedAttributeMap() M("WindowClientArea", "concat(concat(toString(intDiv(toUInt64(%[0]s), 65536)),'x'),toString(toUInt64(%[0]s) % 65536))") - M("UserAgent", "concat(concat(concat(toString(intDiv(toUInt32(%[0]s), 16777216)), ' '), toString(intDiv(toUInt32(%[0]s), 65536) % 256)), (toUInt32(%[0]s) % 65536) == 0 ? '' : concat('.', reinterpretAsString(toUInt32(%[0]s) % 65536)))") - M("UserAgentVersion", "concat(toString(intDiv(toUInt32(%[0]s), 65536)), (toUInt32(%[0]s) % 65536) == 0 ? '' : concat('.', reinterpretAsString(toUInt32(%[0]s) % 65536)))") + M("UserAgent", "concat(concat(concat(toString(intDiv(toUInt32(%[0]s), 16777216)), ' '), toString(intDiv(toUInt32(%[0]s), 65536) % 256)), (toUInt32(%[0]s) % 65536) == 0 ? '' : concat('.', trimRight(reinterpretAsString(toUInt32(%[0]s) % 65536))))") + M("UserAgentVersion", "concat(toString(intDiv(toUInt32(%[0]s), 65536)), (toUInt32(%[0]s) % 65536) == 0 ? '' : concat('.', trimRight(reinterpretAsString(toUInt32(%[0]s) % 65536))))") M("UserAgentMajor", "concat(concat(toString(intDiv(toUInt32(%[0]s), 256)), ' '), toString(toUInt32(%[0]s) % 256))") M("Interests", "bitmaskToList(%s)")