#include "QueryViewsLog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace DB { NamesAndTypesList QueryViewsLogElement::getNamesAndTypes() { auto view_status_datatype = std::make_shared(DataTypeEnum8::Values{ {"QueryStart", static_cast(QUERY_START)}, {"QueryFinish", static_cast(QUERY_FINISH)}, {"ExceptionBeforeStart", static_cast(EXCEPTION_BEFORE_START)}, {"ExceptionWhileProcessing", static_cast(EXCEPTION_WHILE_PROCESSING)}}); auto view_type_datatype = std::make_shared(DataTypeEnum8::Values{ {"Default", static_cast(ViewType::DEFAULT)}, {"Materialized", static_cast(ViewType::MATERIALIZED)}, {"Live", static_cast(ViewType::LIVE)}, {"Window", static_cast(ViewType::WINDOW)}}); return { {"event_date", std::make_shared()}, {"event_time", std::make_shared()}, {"event_time_microseconds", std::make_shared(6)}, {"view_duration_ms", std::make_shared()}, {"initial_query_id", std::make_shared()}, {"view_name", std::make_shared()}, {"view_uuid", std::make_shared()}, {"view_type", std::move(view_type_datatype)}, {"view_query", std::make_shared()}, {"view_target", std::make_shared()}, {"read_rows", std::make_shared()}, {"read_bytes", std::make_shared()}, {"written_rows", std::make_shared()}, {"written_bytes", std::make_shared()}, {"peak_memory_usage", std::make_shared()}, {"ProfileEvents", std::make_shared(std::make_shared(), std::make_shared())}, {"status", std::move(view_status_datatype)}, {"exception_code", std::make_shared()}, {"exception", std::make_shared()}, {"stack_trace", std::make_shared()}}; } NamesAndAliases QueryViewsLogElement::getNamesAndAliases() { return { {"ProfileEvents.Names", {std::make_shared(std::make_shared())}, "mapKeys(ProfileEvents)"}, {"ProfileEvents.Values", {std::make_shared(std::make_shared())}, "mapValues(ProfileEvents)"}}; } void QueryViewsLogElement::appendToBlock(MutableColumns & columns) const { size_t i = 0; columns[i++]->insert(DateLUT::instance().toDayNum(event_time).toUnderType()); // event_date columns[i++]->insert(event_time); columns[i++]->insert(event_time_microseconds); columns[i++]->insert(view_duration_ms); columns[i++]->insertData(initial_query_id.data(), initial_query_id.size()); columns[i++]->insertData(view_name.data(), view_name.size()); columns[i++]->insert(view_uuid); columns[i++]->insert(view_type); columns[i++]->insertData(view_query.data(), view_query.size()); columns[i++]->insertData(view_target.data(), view_target.size()); columns[i++]->insert(read_rows); columns[i++]->insert(read_bytes); columns[i++]->insert(written_rows); columns[i++]->insert(written_bytes); columns[i++]->insert(peak_memory_usage); if (profile_counters) { auto * column = columns[i++].get(); ProfileEvents::dumpToMapColumn(*profile_counters, column, true); } else { columns[i++]->insertDefault(); } columns[i++]->insert(status); columns[i++]->insert(exception_code); columns[i++]->insertData(exception.data(), exception.size()); columns[i++]->insertData(stack_trace.data(), stack_trace.size()); } }