Skip to content

Commit

Permalink
More comments for column for system tables (#59016)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitamikhaylov committed Mar 8, 2024
1 parent e29090d commit f73a8f2
Show file tree
Hide file tree
Showing 62 changed files with 861 additions and 744 deletions.
90 changes: 77 additions & 13 deletions src/Access/Common/QuotaDefs.cpp
Expand Up @@ -49,71 +49,135 @@ String QuotaTypeInfo::valueToStringWithName(QuotaValue value) const

const QuotaTypeInfo & QuotaTypeInfo::get(QuotaType type)
{
static constexpr auto make_info = [](const char * raw_name_, UInt64 output_denominator_)
static constexpr auto make_info = [](const char * raw_name_, String current_usage_description_, String max_allowed_usage_description_, UInt64 output_denominator_)
{
String init_name = raw_name_;
boost::to_lower(init_name);
String init_keyword = raw_name_;
boost::replace_all(init_keyword, "_", " ");
bool init_output_as_float = (output_denominator_ != 1);
return QuotaTypeInfo{raw_name_, std::move(init_name), std::move(init_keyword), init_output_as_float, output_denominator_};
return QuotaTypeInfo
{
.raw_name = raw_name_,
.name = std::move(init_name),
.keyword = std::move(init_keyword),
.current_usage_description = std::move(current_usage_description_),
.max_allowed_usage_description = std::move(max_allowed_usage_description_),
.output_as_float = init_output_as_float,
.output_denominator = output_denominator_
};
};

switch (type)
{
case QuotaType::QUERIES:
{
static const auto info = make_info("QUERIES", 1);
static const auto info = make_info(
"QUERIES",
"The current number of executed queries.",
"The maximum allowed number of queries of all types allowed to be executed.",
1
);
return info;
}
case QuotaType::QUERY_SELECTS:
{
static const auto info = make_info("QUERY_SELECTS", 1);
static const auto info = make_info(
"QUERY_SELECTS",
"The current number of executed SELECT queries.",
"The maximum allowed number of SELECT queries allowed to be executed.",
1
);
return info;
}
case QuotaType::QUERY_INSERTS:
{
static const auto info = make_info("QUERY_INSERTS", 1);
static const auto info = make_info(
"QUERY_INSERTS",
"The current number of executed INSERT queries.",
"The maximum allowed number of INSERT queries allowed to be executed.",
1
);
return info;
}
case QuotaType::ERRORS:
{
static const auto info = make_info("ERRORS", 1);
static const auto info = make_info(
"ERRORS",
"The current number of queries resulted in an error.",
"The maximum number of queries resulted in an error allowed within the specified period of time.",
1
);
return info;
}
case QuotaType::RESULT_ROWS:
{
static const auto info = make_info("RESULT_ROWS", 1);
static const auto info = make_info(
"RESULT_ROWS",
"The current total number of rows in the result set of all queries within the current period of time.",
"The maximum total number of rows in the result set of all queries allowed within the specified period of time.",
1
);
return info;
}
case QuotaType::RESULT_BYTES:
{
static const auto info = make_info("RESULT_BYTES", 1);
static const auto info = make_info(
"RESULT_BYTES",
"The current total number of bytes in the result set of all queries within the current period of time.",
"The maximum total number of bytes in the result set of all queries allowed within the specified period of time.",
1
);
return info;
}
case QuotaType::READ_ROWS:
{
static const auto info = make_info("READ_ROWS", 1);
static const auto info = make_info(
"READ_ROWS",
"The current total number of rows read during execution of all queries within the current period of time.",
"The maximum number of rows to read during execution of all queries allowed within the specified period of time.",
1
);
return info;
}
case QuotaType::READ_BYTES:
{
static const auto info = make_info("READ_BYTES", 1);
static const auto info = make_info(
"READ_BYTES",
"The current total number of bytes read during execution of all queries within the current period of time.",
"The maximum number of bytes to read during execution of all queries allowed within the specified period of time.",
1
);
return info;
}
case QuotaType::EXECUTION_TIME:
{
static const auto info = make_info("EXECUTION_TIME", 1000000000 /* execution_time is stored in nanoseconds */);
static const auto info = make_info(
"EXECUTION_TIME",
"The current total amount of time (in nanoseconds) spent to execute queries within the current period of time",
"The maximum amount of time (in nanoseconds) allowed for all queries to execute within the specified period of time",
1000000000 /* execution_time is stored in nanoseconds */
);
return info;
}
case QuotaType::WRITTEN_BYTES:
{
static const auto info = make_info("WRITTEN_BYTES", 1);
static const auto info = make_info(
"WRITTEN_BYTES",
"The current total number of bytes written during execution of all queries within the current period of time.",
"The maximum number of bytes to written during execution of all queries allowed within the specified period of time.",
1
);
return info;
}
case QuotaType::FAILED_SEQUENTIAL_AUTHENTICATIONS:
{
static const auto info = make_info("FAILED_SEQUENTIAL_AUTHENTICATIONS", 1);
static const auto info = make_info(
"FAILED_SEQUENTIAL_AUtheNTICATIONS",
"The current number of consecutive authentication failures within the current period of time.",
"The maximum number of consecutive authentication failures allowed within the specified period of time.",
1
);
return info;
}
case QuotaType::MAX: break;
Expand Down
2 changes: 2 additions & 0 deletions src/Access/Common/QuotaDefs.h
Expand Up @@ -33,6 +33,8 @@ struct QuotaTypeInfo
const char * const raw_name = "";
const String name; /// Lowercased with underscores, e.g. "result_rows".
const String keyword; /// Uppercased with spaces, e.g. "RESULT ROWS".
const String current_usage_description;
const String max_allowed_usage_description;
const bool output_as_float = false;
const UInt64 output_denominator = 1;
String valueToString(QuotaValue value) const;
Expand Down
9 changes: 6 additions & 3 deletions src/Access/Common/RowPolicyDefs.cpp
Expand Up @@ -33,22 +33,25 @@ String toString(RowPolicyFilterType type)

const RowPolicyFilterTypeInfo & RowPolicyFilterTypeInfo::get(RowPolicyFilterType type_)
{
static constexpr auto make_info = [](const char * raw_name_)
static constexpr auto make_info = [](const char * raw_name_, const String & comment_)
{
String init_name = raw_name_;
boost::to_lower(init_name);
size_t underscore_pos = init_name.find('_');
String init_command = init_name.substr(0, underscore_pos);
boost::to_upper(init_command);
bool init_is_check = (std::string_view{init_name}.substr(underscore_pos + 1) == "check");
return RowPolicyFilterTypeInfo{raw_name_, std::move(init_name), std::move(init_command), init_is_check};
return RowPolicyFilterTypeInfo{raw_name_, std::move(init_name), std::move(init_command), comment_, init_is_check};
};

switch (type_)
{
case RowPolicyFilterType::SELECT_FILTER:
{
static const auto info = make_info("SELECT_FILTER");
static const auto info = make_info(
"SELECT_FILTER",
"Expression which is used for filtering in SELECT queries."
);
return info;
}
#if 0 /// Row-level security for INSERT, UPDATE, DELETE is not implemented yet.
Expand Down
1 change: 1 addition & 0 deletions src/Access/Common/RowPolicyDefs.h
Expand Up @@ -52,6 +52,7 @@ struct RowPolicyFilterTypeInfo
const char * const raw_name;
const String name; /// Lowercased with underscores, e.g. "select_filter".
const String command; /// Uppercased without last word, e.g. "SELECT".
const String description;
const bool is_check; /// E.g. false for SELECT_FILTER.
static const RowPolicyFilterTypeInfo & get(RowPolicyFilterType type);
};
Expand Down
36 changes: 18 additions & 18 deletions src/Interpreters/AsynchronousInsertLog.cpp
Expand Up @@ -33,26 +33,26 @@ ColumnsDescription AsynchronousInsertLogElement::getColumnsDescription()
});

return ColumnsDescription{
{"hostname", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
{"event_date", std::make_shared<DataTypeDate>()},
{"event_time", std::make_shared<DataTypeDateTime>()},
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
{"hostname", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "Hostname of the server executing the query."},
{"event_date", std::make_shared<DataTypeDate>(), "The date when the async insert happened."},
{"event_time", std::make_shared<DataTypeDateTime>(), "The date and time when the async insert finished execution."},
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6), "The date and time when the async insert finished execution with microseconds precision."},

{"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>()},
{"rows", std::make_shared<DataTypeUInt64>()},
{"exception", std::make_shared<DataTypeString>()},
{"status", type_status},
{"data_kind", type_data_kind},
{"query", std::make_shared<DataTypeString>(), "Query string."},
{"database", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "The name of the database the table is in."},
{"table", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "Table name."},
{"format", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "Format name."},
{"query_id", std::make_shared<DataTypeString>(), "ID of the initial query."},
{"bytes", std::make_shared<DataTypeUInt64>(), "Number of inserted bytes."},
{"rows", std::make_shared<DataTypeUInt64>(), "Number of inserted rows."},
{"exception", std::make_shared<DataTypeString>(), "Exception message."},
{"status", type_status, "Status of the view. Values: 'Ok' = 1 — Successful insert, 'ParsingError' = 2 — Exception when parsing the data, 'FlushError' = 3 — Exception when flushing the data"},
{"data_kind", type_data_kind, "The status of the data. Value: 'Parsed' and 'Preprocessed'."},

{"flush_time", std::make_shared<DataTypeDateTime>()},
{"flush_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
{"flush_query_id", std::make_shared<DataTypeString>()},
{"timeout_milliseconds", std::make_shared<DataTypeUInt64>()},
{"flush_time", std::make_shared<DataTypeDateTime>(), "The date and time when the flush happened."},
{"flush_time_microseconds", std::make_shared<DataTypeDateTime64>(6), "The date and time when the flush happened with microseconds precision."},
{"flush_query_id", std::make_shared<DataTypeString>(), "ID of the flush query."},
{"timeout_milliseconds", std::make_shared<DataTypeUInt64>(), "The adaptive timeout calculated for this entry."},
};
}

Expand Down
36 changes: 18 additions & 18 deletions src/Interpreters/BackupLog.cpp
Expand Up @@ -22,24 +22,24 @@ ColumnsDescription BackupLogElement::getColumnsDescription()
{
return ColumnsDescription
{
{"hostname", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
{"event_date", std::make_shared<DataTypeDate>()},
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
{"id", std::make_shared<DataTypeString>()},
{"name", std::make_shared<DataTypeString>()},
{"base_backup_name", std::make_shared<DataTypeString>()},
{"query_id", std::make_shared<DataTypeString>()},
{"status", std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues())},
{"error", std::make_shared<DataTypeString>()},
{"start_time", std::make_shared<DataTypeDateTime>()},
{"end_time", std::make_shared<DataTypeDateTime>()},
{"num_files", std::make_shared<DataTypeUInt64>()},
{"total_size", std::make_shared<DataTypeUInt64>()},
{"num_entries", std::make_shared<DataTypeUInt64>()},
{"uncompressed_size", std::make_shared<DataTypeUInt64>()},
{"compressed_size", std::make_shared<DataTypeUInt64>()},
{"files_read", std::make_shared<DataTypeUInt64>()},
{"bytes_read", std::make_shared<DataTypeUInt64>()},
{"hostname", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "Hostname of the server executing the query."},
{"event_date", std::make_shared<DataTypeDate>(), "Date of the entry."},
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6), "Time of the entry with microseconds precision."},
{"id", std::make_shared<DataTypeString>(), "Identifier of the backup or restore operation."},
{"name", std::make_shared<DataTypeString>(), "Name of the backup storage (the contents of the FROM or TO clause)."},
{"base_backup_name", std::make_shared<DataTypeString>(), "The name of base backup in case incremental one."},
{"query_id", std::make_shared<DataTypeString>(), "The ID of a query associated with a backup operation."},
{"status", std::make_shared<DataTypeEnum8>(getBackupStatusEnumValues()), "Operation status."},
{"error", std::make_shared<DataTypeString>(), "Error message of the failed operation (empty string for successful operations)."},
{"start_time", std::make_shared<DataTypeDateTime>(), "Start time of the operation."},
{"end_time", std::make_shared<DataTypeDateTime>(), "End time of the operation."},
{"num_files", std::make_shared<DataTypeUInt64>(), "Number of files stored in the backup."},
{"total_size", std::make_shared<DataTypeUInt64>(), "Total size of files stored in the backup."},
{"num_entries", std::make_shared<DataTypeUInt64>(), "Number of entries in the backup, i.e. the number of files inside the folder if the backup is stored as a folder, or the number of files inside the archive if the backup is stored as an archive. It is not the same as num_files if it's an incremental backup or if it contains empty files or duplicates. The following is always true: num_entries <= num_files."},
{"uncompressed_size", std::make_shared<DataTypeUInt64>(), "Uncompressed size of the backup."},
{"compressed_size", std::make_shared<DataTypeUInt64>(), "Compressed size of the backup. If the backup is not stored as an archive it equals to uncompressed_size."},
{"files_read", std::make_shared<DataTypeUInt64>(), "Number of files read during the restore operation."},
{"bytes_read", std::make_shared<DataTypeUInt64>(), "Total size of files read during the restore operation."},
};
}

Expand Down
26 changes: 13 additions & 13 deletions src/Interpreters/BlobStorageLog.cpp
Expand Up @@ -26,23 +26,23 @@ ColumnsDescription BlobStorageLogElement::getColumnsDescription()

return ColumnsDescription
{
{"event_date", std::make_shared<DataTypeDate>()},
{"event_time", std::make_shared<DataTypeDateTime>()},
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6)},
{"event_date", std::make_shared<DataTypeDate>(), "Date of the event."},
{"event_time", std::make_shared<DataTypeDateTime>(), "Time of the event."},
{"event_time_microseconds", std::make_shared<DataTypeDateTime64>(6), "Time of the event with microseconds precision."},

{"event_type", event_enum_type},
{"event_type", event_enum_type, "Type of the event. Possible values: 'Upload', 'Delete', 'MultiPartUploadCreate', 'MultiPartUploadWrite', 'MultiPartUploadComplete', 'MultiPartUploadAbort'"},

{"query_id", std::make_shared<DataTypeString>()},
{"thread_id", std::make_shared<DataTypeUInt64>()},
{"thread_name", std::make_shared<DataTypeString>()},
{"query_id", std::make_shared<DataTypeString>(), "Identifier of the query associated with the event, if any."},
{"thread_id", std::make_shared<DataTypeUInt64>(), "Identifier of the thread performing the operation."},
{"thread_name", std::make_shared<DataTypeString>(), "Name of the thread performing the operation."},

{"disk_name", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>())},
{"bucket", std::make_shared<DataTypeString>()},
{"remote_path", std::make_shared<DataTypeString>()},
{"local_path", std::make_shared<DataTypeString>()},
{"data_size", std::make_shared<DataTypeUInt64>()},
{"disk_name", std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>()), "Name of the associated disk."},
{"bucket", std::make_shared<DataTypeString>(), "Name of the bucket."},
{"remote_path", std::make_shared<DataTypeString>(), "Path to the remote resource."},
{"local_path", std::make_shared<DataTypeString>(), "Path to the metadata file on the local system, which references the remote resource."},
{"data_size", std::make_shared<DataTypeUInt64>(), "Size of the data involved in the upload event."},

{"error", std::make_shared<DataTypeString>()},
{"error", std::make_shared<DataTypeString>(), "Error message associated with the event, if any."},
};
}

Expand Down

0 comments on commit f73a8f2

Please sign in to comment.