diff --git a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h index 4797922d837..1d7d39f1b9e 100644 --- a/dbms/src/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h +++ b/dbms/src/Storages/MergeTree/ReplicatedMergeTreeLogEntry.h @@ -77,6 +77,8 @@ struct ReplicatedMergeTreeLogEntryData bool deduplicate = false; /// Do deduplicate on merge String column_name; + /// Force filter by TTL in 'OPTIMIZE ... FINAL' query to remove expired values from old parts + /// without TTL infos or with outdated TTL infos, e.g. after 'ALTER ... MODIFY TTL' query. bool force_ttl = false; /// For DROP_RANGE, true means that the parts need not be deleted, but moved to the `detached` directory. diff --git a/dbms/src/Storages/StorageMergeTree.cpp b/dbms/src/Storages/StorageMergeTree.cpp index 589a5ad2af2..69020023df5 100644 --- a/dbms/src/Storages/StorageMergeTree.cpp +++ b/dbms/src/Storages/StorageMergeTree.cpp @@ -590,7 +590,10 @@ bool StorageMergeTree::merge( try { + /// Force filter by TTL in 'OPTIMIZE ... FINAL' query to remove expired values from old parts + /// without TTL infos or with outdated TTL infos, e.g. after 'ALTER ... MODIFY TTL' query. bool force_ttl = (final && (hasTableTTL() || hasAnyColumnTTL())); + new_part = merger_mutator.mergePartsToTemporaryPart( future_part, *merge_entry, time(nullptr), merging_tagger->reserved_space.get(), deduplicate, force_ttl);