mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 16:12:01 +00:00
Merge pull request #17438 from spongedu/add_ttl_option_for_syslog
Support configure System log table`s ttl in config.xml
This commit is contained in:
commit
12d1fa6456
@ -581,7 +581,7 @@
|
||||
<database>system</database>
|
||||
<table>query_log</table>
|
||||
<!--
|
||||
PARTITION BY expr https://clickhouse.yandex/docs/en/table_engines/custom_partitioning_key/
|
||||
PARTITION BY expr: https://clickhouse.yandex/docs/en/table_engines/custom_partitioning_key/
|
||||
Example:
|
||||
event_date
|
||||
toMonday(event_date)
|
||||
@ -589,6 +589,15 @@
|
||||
toStartOfHour(event_time)
|
||||
-->
|
||||
<partition_by>toYYYYMM(event_date)</partition_by>
|
||||
<!--
|
||||
Table TTL specification: https://clickhouse.tech/docs/en/engines/table-engines/mergetree-family/mergetree/#mergetree-table-ttl
|
||||
Example:
|
||||
event_date + INTERVAL 1 WEEK
|
||||
event_date + INTERVAL 7 DAY DELETE
|
||||
event_date + INTERVAL 2 WEEK TO DISK 'bbb'
|
||||
|
||||
<ttl>event_date + INTERVAL 30 DAY DELETE</ttl>
|
||||
-->
|
||||
|
||||
<!-- Instead of partition_by, you can provide full engine expression (starting with ENGINE = ) with parameters,
|
||||
Example: <engine>ENGINE = MergeTree PARTITION BY toYYYYMM(event_date) ORDER BY (event_date, event_time) SETTINGS index_granularity = 1024</engine>
|
||||
|
@ -57,6 +57,10 @@ std::shared_ptr<TSystemLog> createSystemLog(
|
||||
throw Exception("If 'engine' is specified for system table, "
|
||||
"PARTITION BY parameters should be specified directly inside 'engine' and 'partition_by' setting doesn't make sense",
|
||||
ErrorCodes::BAD_ARGUMENTS);
|
||||
if (config.has(config_prefix + ".ttl"))
|
||||
throw Exception("If 'engine' is specified for system table, "
|
||||
"TTL parameters should be specified directly inside 'engine' and 'ttl' setting doesn't make sense",
|
||||
ErrorCodes::BAD_ARGUMENTS);
|
||||
engine = config.getString(config_prefix + ".engine");
|
||||
}
|
||||
else
|
||||
@ -65,6 +69,9 @@ std::shared_ptr<TSystemLog> createSystemLog(
|
||||
engine = "ENGINE = MergeTree";
|
||||
if (!partition_by.empty())
|
||||
engine += " PARTITION BY (" + partition_by + ")";
|
||||
String ttl = config.getString(config_prefix + ".ttl", "");
|
||||
if (!ttl.empty())
|
||||
engine += " TTL " + ttl;
|
||||
engine += " ORDER BY (event_date, event_time)";
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user