2022-10-03 18:52:14 +00:00
|
|
|
#include <Interpreters/AsynchronousInsertLog.h>
|
|
|
|
|
2023-10-23 00:45:58 +00:00
|
|
|
#include <base/getFQDNOrHostName.h>
|
2022-10-03 18:52:14 +00:00
|
|
|
#include <DataTypes/DataTypeDate.h>
|
|
|
|
#include <DataTypes/DataTypeDateTime.h>
|
|
|
|
#include <DataTypes/DataTypeDateTime64.h>
|
|
|
|
#include <DataTypes/DataTypeLowCardinality.h>
|
|
|
|
#include <DataTypes/DataTypeString.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <DataTypes/DataTypeEnum.h>
|
|
|
|
#include <Parsers/ASTInsertQuery.h>
|
|
|
|
#include <Parsers/queryToString.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2024-01-12 15:39:22 +00:00
|
|
|
ColumnsDescription AsynchronousInsertLogElement::getColumnsDescription()
|
2022-10-03 18:52:14 +00:00
|
|
|
{
|
|
|
|
auto type_status = std::make_shared<DataTypeEnum8>(
|
|
|
|
DataTypeEnum8::Values
|
|
|
|
{
|
2022-10-04 14:19:05 +00:00
|
|
|
{"Ok", static_cast<Int8>(Status::Ok)},
|
2022-10-03 18:52:14 +00:00
|
|
|
{"ParsingError", static_cast<Int8>(Status::ParsingError)},
|
|
|
|
{"FlushError", static_cast<Int8>(Status::FlushError)},
|
|
|
|
});
|
|
|
|
|
2023-10-20 16:39:48 +00:00
|
|
|
auto type_data_kind = std::make_shared<DataTypeEnum8>(
|
|
|
|
DataTypeEnum8::Values
|
|
|
|
{
|
|
|
|
{"Parsed", static_cast<Int8>(DataKind::Parsed)},
|
|
|
|
{"Preprocessed", static_cast<Int8>(DataKind::Preprocessed)},
|
|
|
|
});
|
|
|
|
|
2024-01-17 23:35:44 +00:00
|
|
|
return ColumnsDescription{
|
2023-10-23 00:45:58 +00:00
|
|
|
{"hostname", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
2022-10-03 18:52:14 +00:00
|
|
|
{"event_date", std::make_shared<DataTypeDate>()},
|
|
|
|
{"event_time", std::make_shared<DataTypeDateTime>()},
|
|
|
|
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
|
|
|
|
|
|
|
|
{"query", std::make_shared<DataTypeString>()},
|
|
|
|
{"database", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
|
|
|
{"table", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
|
|
|
{"format", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
|
|
|
|
{"query_id", std::make_shared<DataTypeString>()},
|
|
|
|
{"bytes", std::make_shared<DataTypeUInt64>()},
|
2023-04-25 00:31:55 +00:00
|
|
|
{"rows", std::make_shared<DataTypeUInt64>()},
|
2022-10-03 18:52:14 +00:00
|
|
|
{"exception", std::make_shared<DataTypeString>()},
|
|
|
|
{"status", type_status},
|
2023-10-20 16:39:48 +00:00
|
|
|
{"data_kind", type_data_kind},
|
2022-10-03 18:52:14 +00:00
|
|
|
|
|
|
|
{"flush_time", std::make_shared<DataTypeDateTime>()},
|
|
|
|
{"flush_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
|
|
|
|
{"flush_query_id", std::make_shared<DataTypeString>()},
|
2024-01-17 23:35:44 +00:00
|
|
|
{"timeout_milliseconds", std::make_shared<DataTypeUInt64>()},
|
2022-10-03 18:52:14 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
void AsynchronousInsertLogElement::appendToBlock(MutableColumns & columns) const
|
|
|
|
{
|
|
|
|
size_t i = 0;
|
|
|
|
|
2023-10-23 00:45:58 +00:00
|
|
|
columns[i++]->insert(getFQDNOrHostName());
|
2022-10-03 18:52:14 +00:00
|
|
|
auto event_date = DateLUT::instance().toDayNum(event_time).toUnderType();
|
|
|
|
columns[i++]->insert(event_date);
|
|
|
|
columns[i++]->insert(event_time);
|
|
|
|
columns[i++]->insert(event_time_microseconds);
|
|
|
|
|
2023-06-19 11:39:30 +00:00
|
|
|
columns[i++]->insert(query_for_logging);
|
|
|
|
columns[i++]->insert(database);
|
|
|
|
columns[i++]->insert(table);
|
|
|
|
columns[i++]->insert(format);
|
2022-10-03 18:52:14 +00:00
|
|
|
columns[i++]->insert(query_id);
|
|
|
|
columns[i++]->insert(bytes);
|
2023-04-25 00:31:55 +00:00
|
|
|
columns[i++]->insert(rows);
|
2022-10-03 18:52:14 +00:00
|
|
|
columns[i++]->insert(exception);
|
|
|
|
columns[i++]->insert(status);
|
2023-10-20 16:39:48 +00:00
|
|
|
columns[i++]->insert(data_kind);
|
2022-10-03 18:52:14 +00:00
|
|
|
|
|
|
|
columns[i++]->insert(flush_time);
|
|
|
|
columns[i++]->insert(flush_time_microseconds);
|
|
|
|
columns[i++]->insert(flush_query_id);
|
2024-01-17 23:35:44 +00:00
|
|
|
columns[i++]->insert(timeout_milliseconds);
|
2022-10-03 18:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|