From f7a5d2a215e53dc5430cf3d67d119abda3fca9b7 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 17 Jul 2013 20:29:47 +0000 Subject: [PATCH] dbms: OLAP-compatibility: reverted prev. modification [#CONV-8238]. --- dbms/src/Server/OLAPQueryConverter.cpp | 59 ++++++++++++++++++++++++++ dbms/src/Server/OLAPQueryConverter.h | 1 + 2 files changed, 60 insertions(+) diff --git a/dbms/src/Server/OLAPQueryConverter.cpp b/dbms/src/Server/OLAPQueryConverter.cpp index f1579dec726..3116198d583 100644 --- a/dbms/src/Server/OLAPQueryConverter.cpp +++ b/dbms/src/Server/OLAPQueryConverter.cpp @@ -15,6 +15,7 @@ QueryConverter::QueryConverter(Poco::Util::AbstractConfiguration & config) fillFormattedAttributeMap(); fillNumericAttributeMap(); + fillFormattingAggregatedAttributeMap(); attribute_metadatas = GetOLAPAttributeMetadata(); } @@ -584,5 +585,63 @@ void QueryConverter::fillFormattedAttributeMap() #undef M } +void QueryConverter::fillFormattingAggregatedAttributeMap() +{ +#define M(a, b) formatting_aggregated_attribute_map[a] = b; + 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)"; + + M("VisitStartDateTime", todatetime) + M("VisitStartDate", todate) + M("VisitStartWeek", todate) + M("VisitStartTime", cuttime) + + M("VisitStartDateTimeRoundedToMinute", todatetime) + M("VisitStartDateTimeRoundedToHour", todatetime) + M("VisitStartDateRoundedToMonth", todate) + M("VisitStartTimeRoundedToMinute", cuttime) + + M("FirstVisitDateTime", todatetime) + M("FirstVisitDate", todate) + M("FirstVisitWeek", todate) + M("FirstVisitTime", cuttime) + + M("PredLastVisitDate", todate) + M("PredLastVisitWeek", todate) + + M("ClientDateTime", todatetime) + M("ClientTime", cuttime) + + M("UserIDCreateDateTime", todatetime) + M("UserIDCreateDate", todate) + + M("DotNet", "concat(concat(toString(intDiv(toUInt32(%[0]s), 256)), '.'), toString(modulo(toUInt32(%[0]s), 256)))") + + M("Flash", "concat(concat(toString(intDiv(toUInt32(%[0]s), 256)), '.'), toString(modulo(toUInt32(%[0]s), 256)))") + + M("Silverlight", "concat(concat(concat(concat(concat(concat(toString(intDiv(toUInt64(%[0]s), 72057594037927936)), '.'), toString(modulo(intDiv(toUInt64(%[0]s), 281474976710656), 256))), '.'), toString(modulo(intDiv(toUInt64(%[0]s), 65536), 4294967296))), '.'), toString(modulo(toUInt64(%[0]s), 65536)))") + + M("MobilePhoneModel", tostring) + M("BrowserLanguage", tostring) + M("BrowserCountry", tostring) + M("TopLevelDomain", tostring) + M("URLScheme", tostring) + + M("ClientIP", "IPv4NumToString(%[0]s)") + M("Resolution", "concat(concat(concat(concat(toString(intDiv(toUInt64(%[0]s), 16777216)),'x'),toString(intDiv(toUInt64(%[0]s), 256) %% 65536)),'x'),toString(toUInt64(%[0]s) %% 256))") + M("ResolutionWidthHeight","concat(concat(toString(intDiv(toUInt64(%[0]s), 65536)),'x'),toString(toUInt64(%[0]s) %% 65536))") + + 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("UserAgentMajor", "concat(concat(toString(intDiv(toUInt32(%[0]s), 256)), ' '), toString(toUInt32(%[0]s) %% 256))") + + M("Interests", "bitmaskToList(%s)") +#undef M +} + } } diff --git a/dbms/src/Server/OLAPQueryConverter.h b/dbms/src/Server/OLAPQueryConverter.h index f3c48666983..4aa816870d6 100644 --- a/dbms/src/Server/OLAPQueryConverter.h +++ b/dbms/src/Server/OLAPQueryConverter.h @@ -43,6 +43,7 @@ private: void fillFormattedAttributeMap(); void fillNumericAttributeMap(); + void fillFormattingAggregatedAttributeMap(); std::string table_for_single_counter; std::string table_for_all_counters;