mirror of https://github.com/ByConity/ByConity
Merge pull request #6796 from CurtizJ/fix-flappy-ttl-test
Fix column TTL with user defaults.
This commit is contained in:
commit
152dba1b2e
|
@ -34,7 +34,7 @@ TTLBlockInputStream::TTLBlockInputStream(
|
|||
ASTPtr default_expr_list = std::make_shared<ASTExpressionList>();
|
||||
for (const auto & [name, ttl_info] : old_ttl_infos.columns_ttl)
|
||||
{
|
||||
if (ttl_info.min <= current_time)
|
||||
if (force || isTTLExpired(ttl_info.min))
|
||||
{
|
||||
new_ttl_infos.columns_ttl.emplace(name, MergeTreeDataPart::TTLInfo{});
|
||||
empty_columns.emplace(name);
|
||||
|
@ -51,7 +51,7 @@ TTLBlockInputStream::TTLBlockInputStream(
|
|||
new_ttl_infos.columns_ttl.emplace(name, ttl_info);
|
||||
}
|
||||
|
||||
if (old_ttl_infos.table_ttl.min > current_time)
|
||||
if (!force && !isTTLExpired(old_ttl_infos.table_ttl.min))
|
||||
new_ttl_infos.table_ttl = old_ttl_infos.table_ttl;
|
||||
|
||||
if (!default_expr_list->children.empty())
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
3
|
||||
4
|
||||
777
|
||||
777
|
|
@ -0,0 +1,14 @@
|
|||
DROP TABLE IF EXISTS ttl_with_default;
|
||||
|
||||
CREATE TABLE ttl_with_default (d DateTime, a Int default 777 ttl d + interval 5 SECOND) ENGINE = MergeTree ORDER BY d;
|
||||
INSERT INTO ttl_with_default VALUES (now() - 1000, 1) (now() - 1000, 2) (now() + 1000, 3)(now() + 1000, 4);
|
||||
SELECT sleep(0.7) FORMAT Null; -- wait if very fast merge happen
|
||||
OPTIMIZE TABLE ttl_with_default FINAL;
|
||||
|
||||
-- check that after second merge there are still user defaults in column
|
||||
SELECT sleep(0.7) FORMAT Null;
|
||||
OPTIMIZE TABLE ttl_with_default FINAL;
|
||||
|
||||
SELECT a FROM ttl_with_default ORDER BY a;
|
||||
|
||||
DROP TABLE ttl_with_default;
|
Loading…
Reference in New Issue