2021-06-15 17:10:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-06-18 13:44:08 +00:00
|
|
|
#include <chrono>
|
2021-06-15 17:10:41 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <Columns/IColumn.h>
|
|
|
|
#include <Core/Block.h>
|
|
|
|
#include <Core/SettingsEnums.h>
|
|
|
|
#include <Core/Types.h>
|
|
|
|
#include <Core/UUID.h>
|
|
|
|
#include <Interpreters/SystemLog.h>
|
|
|
|
#include <common/types.h>
|
|
|
|
|
|
|
|
namespace ProfileEvents
|
|
|
|
{
|
|
|
|
class Counters;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2021-06-18 13:44:08 +00:00
|
|
|
class ThreadStatus;
|
|
|
|
|
|
|
|
struct QueryViewsLogElement
|
2021-06-15 17:10:41 +00:00
|
|
|
{
|
2021-06-22 11:39:53 +00:00
|
|
|
enum class ViewStatus : int8_t
|
|
|
|
{
|
|
|
|
INIT = 1,
|
|
|
|
WRITTEN_PREFIX = 2,
|
|
|
|
WRITTEN_BLOCK = 3,
|
|
|
|
WRITTEN_SUFFIX = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-06-18 13:44:08 +00:00
|
|
|
enum class ViewType : int8_t
|
|
|
|
{
|
2021-06-22 11:39:53 +00:00
|
|
|
DEFAULT = 1,
|
|
|
|
MATERIALIZED = 2,
|
|
|
|
LIVE = 3
|
2021-06-18 13:44:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ViewRuntimeStats
|
|
|
|
{
|
2021-06-18 16:25:19 +00:00
|
|
|
String target_name;
|
2021-06-18 13:44:08 +00:00
|
|
|
ViewType type = ViewType::DEFAULT;
|
2021-06-23 14:14:30 +00:00
|
|
|
std::shared_ptr<ThreadStatus> thread_status = nullptr;
|
2021-06-18 16:25:19 +00:00
|
|
|
UInt64 elapsed_ms = 0;
|
|
|
|
std::chrono::time_point<std::chrono::system_clock> event_time;
|
2021-06-22 11:39:53 +00:00
|
|
|
ViewStatus event_status = ViewStatus::INIT;
|
2021-06-18 16:25:19 +00:00
|
|
|
|
2021-06-22 11:39:53 +00:00
|
|
|
void setStatus(ViewStatus s)
|
2021-06-18 16:25:19 +00:00
|
|
|
{
|
|
|
|
event_status = s;
|
|
|
|
event_time = std::chrono::system_clock::now();
|
|
|
|
}
|
2021-06-18 13:44:08 +00:00
|
|
|
};
|
2021-06-15 17:10:41 +00:00
|
|
|
|
|
|
|
time_t event_time{};
|
|
|
|
Decimal64 event_time_microseconds{};
|
2021-06-18 13:44:08 +00:00
|
|
|
UInt64 view_duration_ms{};
|
2021-06-15 17:10:41 +00:00
|
|
|
|
|
|
|
String initial_query_id;
|
2021-06-18 13:44:08 +00:00
|
|
|
String view_name;
|
|
|
|
UUID view_uuid{UUIDHelpers::Nil};
|
|
|
|
ViewType view_type{ViewType::DEFAULT};
|
|
|
|
String view_query;
|
|
|
|
String view_target;
|
2021-06-15 17:10:41 +00:00
|
|
|
|
|
|
|
UInt64 read_rows{};
|
|
|
|
UInt64 read_bytes{};
|
|
|
|
UInt64 written_rows{};
|
|
|
|
UInt64 written_bytes{};
|
|
|
|
Int64 peak_memory_usage{};
|
|
|
|
std::shared_ptr<ProfileEvents::Counters> profile_counters;
|
|
|
|
|
2021-06-22 11:39:53 +00:00
|
|
|
ViewStatus status;
|
2021-06-15 17:10:41 +00:00
|
|
|
Int32 exception_code{};
|
|
|
|
String exception;
|
|
|
|
String stack_trace;
|
|
|
|
|
2021-06-18 13:44:08 +00:00
|
|
|
static std::string name() { return "QueryViewsLog"; }
|
2021-06-15 17:10:41 +00:00
|
|
|
|
|
|
|
static Block createBlock();
|
|
|
|
void appendToBlock(MutableColumns & columns) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-06-18 13:44:08 +00:00
|
|
|
class QueryViewsLog : public SystemLog<QueryViewsLogElement>
|
2021-06-15 17:10:41 +00:00
|
|
|
{
|
2021-06-18 13:44:08 +00:00
|
|
|
using SystemLog<QueryViewsLogElement>::SystemLog;
|
2021-06-15 17:10:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|