Merge pull request #63200 from litlig/parts_column_ttl

Add column ttl info to system info
This commit is contained in:
Alexey Milovidov 2024-05-05 17:13:50 +00:00 committed by GitHub
commit 8aedecf100
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 48 additions and 0 deletions

View File

@ -65,6 +65,8 @@ StorageSystemPartsColumns::StorageSystemPartsColumns(const StorageID & table_id_
{"column_data_uncompressed_bytes", std::make_shared<DataTypeUInt64>(), "Total size of the decompressed data in the column, in bytes."},
{"column_marks_bytes", std::make_shared<DataTypeUInt64>(), "The size of the marks for column, in bytes."},
{"column_modification_time", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeDateTime>()), "The last time the column was modified."},
{"column_ttl_min", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeDateTime>()), "The minimum value of the calculated TTL expression of the column."},
{"column_ttl_max", std::make_shared<DataTypeNullable>(std::make_shared<DataTypeDateTime>()), "The maximum value of the calculated TTL expression of the column."},
{"serialization_kind", std::make_shared<DataTypeString>(), "Kind of serialization of a column"},
{"substreams", std::make_shared<DataTypeArray>(std::make_shared<DataTypeString>()), "Names of substreams to which column is serialized"},
@ -250,6 +252,21 @@ void StorageSystemPartsColumns::processNextStorage(
else
columns[res_index++]->insertDefault();
}
bool column_has_ttl = part->ttl_infos.columns_ttl.contains(column.name);
if (columns_mask[src_index++])
{
if (column_has_ttl)
columns[res_index++]->insert(static_cast<UInt32>(part->ttl_infos.columns_ttl[column.name].min));
else
columns[res_index++]->insertDefault();
}
if (columns_mask[src_index++])
{
if (column_has_ttl)
columns[res_index++]->insert(static_cast<UInt32>(part->ttl_infos.columns_ttl[column.name].max));
else
columns[res_index++]->insertDefault();
}
auto serialization = part->getSerialization(column.name);
if (columns_mask[src_index++])

View File

@ -565,6 +565,8 @@ CREATE TABLE system.parts_columns
`column_data_uncompressed_bytes` UInt64,
`column_marks_bytes` UInt64,
`column_modification_time` Nullable(DateTime),
`column_ttl_min` Nullable(DateTime),
`column_ttl_max` Nullable(DateTime),
`serialization_kind` String,
`substreams` Array(String),
`filenames` Array(String),

View File

@ -0,0 +1,4 @@
all_1_1_0 timestamp DateTime \N \N
all_1_1_0 x UInt32 2100-02-01 00:00:00 2100-02-01 00:00:00
all_1_1_0 y String 2100-01-02 00:00:00 2100-01-02 00:00:00
all_1_1_0 z String \N \N

View File

@ -0,0 +1,25 @@
DROP TABLE IF EXISTS test_03143;
CREATE TABLE test_03143 (
timestamp DateTime,
x UInt32 TTL timestamp + INTERVAL 1 MONTH,
y String TTL timestamp + INTERVAL 1 DAY,
z String
)
ENGINE = MergeTree
ORDER BY tuple();
INSERT INTO test_03143 VALUES ('2100-01-01', 123, 'Hello, world!', 'xxx yyy');
SELECT
name,
column,
type,
column_ttl_min,
column_ttl_max
FROM system.parts_columns
WHERE table = 'test_03143' and database = currentDatabase()
ORDER BY name, column;
DROP TABLE IF EXISTS test_03143;