This commit is contained in:
Nikita Mikhaylov 2019-08-01 14:11:08 +03:00
parent 9116c08959
commit 406f7a2bfe

View File

@ -11,6 +11,7 @@
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypeFactory.h>
#include <DataTypes/DataTypeEnum.h>
#include <Interpreters/QueryLog.h>
#include <Interpreters/ProfileEventsExt.h>
#include <Poco/Net/IPAddress.h>
@ -20,11 +21,23 @@
namespace DB
{
template <> struct NearestFieldTypeImpl<QueryLogElement::Type> { using Type = UInt64; };
Block QueryLogElement::createBlock()
{
auto query_status_datatype = std::make_shared<DataTypeEnum8>(
DataTypeEnum8::Values
{
{"QUERY_START", static_cast<Int8>(QUERY_START)},
{"QUERY_FINISH", static_cast<Int8>(QUERY_FINISH)},
{"EXCEPTION_BEFORE_START", static_cast<Int8>(EXCEPTION_BEFORE_START)},
{"EXCEPTION_WHILE_PROCESSING", static_cast<Int8>(EXCEPTION_WHILE_PROCESSING)}
});
return
{
{std::make_shared<DataTypeUInt8>(), "type"},
{std::move(query_status_datatype), "type"},
{std::make_shared<DataTypeDate>(), "event_date"},
{std::make_shared<DataTypeDateTime>(), "event_time"},
{std::make_shared<DataTypeDateTime>(), "query_start_time"},
@ -80,7 +93,7 @@ void QueryLogElement::appendToBlock(Block & block) const
size_t i = 0;
columns[i++]->insert(UInt64(type));
columns[i++]->insert(type);
columns[i++]->insert(DateLUT::instance().toDayNum(event_time));
columns[i++]->insert(event_time);
columns[i++]->insert(query_start_time);