#include "QueryThreadLog.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace DB { NamesAndTypesList QueryThreadLogElement::getNamesAndTypes() { return { {"event_date", std::make_shared()}, {"event_time", std::make_shared()}, {"event_time_microseconds", std::make_shared(6)}, {"query_start_time", std::make_shared()}, {"query_start_time_microseconds", std::make_shared(6)}, {"query_duration_ms", std::make_shared()}, {"read_rows", std::make_shared()}, {"read_bytes", std::make_shared()}, {"written_rows", std::make_shared()}, {"written_bytes", std::make_shared()}, {"memory_usage", std::make_shared()}, {"peak_memory_usage", std::make_shared()}, {"thread_name", std::make_shared()}, {"thread_id", std::make_shared()}, {"master_thread_id", std::make_shared()}, {"current_database", std::make_shared()}, {"query", std::make_shared()}, {"normalized_query_hash", std::make_shared()}, {"is_initial_query", std::make_shared()}, {"user", std::make_shared()}, {"query_id", std::make_shared()}, {"address", DataTypeFactory::instance().get("IPv6")}, {"port", std::make_shared()}, {"initial_user", std::make_shared()}, {"initial_query_id", std::make_shared()}, {"initial_address", DataTypeFactory::instance().get("IPv6")}, {"initial_port", std::make_shared()}, {"initial_query_start_time", std::make_shared()}, {"initial_query_start_time_microseconds", std::make_shared(6)}, {"interface", std::make_shared()}, {"os_user", std::make_shared()}, {"client_hostname", std::make_shared()}, {"client_name", std::make_shared()}, {"client_revision", std::make_shared()}, {"client_version_major", std::make_shared()}, {"client_version_minor", std::make_shared()}, {"client_version_patch", std::make_shared()}, {"http_method", std::make_shared()}, {"http_user_agent", std::make_shared()}, {"http_referer", std::make_shared()}, {"forwarded_for", std::make_shared()}, {"quota_key", std::make_shared()}, {"revision", std::make_shared()}, {"ProfileEvents", std::make_shared(std::make_shared(), std::make_shared())}, }; } NamesAndAliases QueryThreadLogElement::getNamesAndAliases() { return { {"ProfileEvents.Names", {std::make_shared(std::make_shared())}, "mapKeys(ProfileEvents)"}, {"ProfileEvents.Values", {std::make_shared(std::make_shared())}, "mapValues(ProfileEvents)"} }; } void QueryThreadLogElement::appendToBlock(MutableColumns & columns) const { size_t i = 0; columns[i++]->insert(DateLUT::instance().toDayNum(event_time).toUnderType()); columns[i++]->insert(event_time); columns[i++]->insert(event_time_microseconds); columns[i++]->insert(query_start_time); columns[i++]->insert(query_start_time_microseconds); columns[i++]->insert(query_duration_ms); columns[i++]->insert(read_rows); columns[i++]->insert(read_bytes); columns[i++]->insert(written_rows); columns[i++]->insert(written_bytes); columns[i++]->insert(memory_usage); columns[i++]->insert(peak_memory_usage); columns[i++]->insertData(thread_name.data(), thread_name.size()); columns[i++]->insert(thread_id); columns[i++]->insert(master_thread_id); columns[i++]->insertData(current_database.data(), current_database.size()); columns[i++]->insertData(query.data(), query.size()); columns[i++]->insert(normalized_query_hash); QueryLogElement::appendClientInfo(client_info, columns, i); columns[i++]->insert(ClickHouseRevision::getVersionRevision()); if (profile_counters) { auto * column = columns[i++].get(); ProfileEvents::dumpToMapColumn(*profile_counters, column, true); } else { columns[i++]->insertDefault(); } } }