pass proper time for TTL

This commit is contained in:
CurtizJ 2020-02-19 20:48:44 +03:00
parent 803d9da496
commit 2f30a1350b
6 changed files with 10 additions and 10 deletions

View File

@ -459,9 +459,6 @@ public:
/// Returns names of primary key + secondary sorting columns
virtual Names getSortingKeyColumns() const { return {}; }
/// Returns columns that could be updated by applying TTL rules
virtual Names getColumnsUpdatedByTTL() const { return {}; }
/// Returns columns, whose dependencies (skip indices, TTL expressions)
/// would be affected if we will update @updated_columns set of columns.
virtual ColumnDependencies getColumnDependencies(const NameSet & /* updated_columns */) const { return {}; }

View File

@ -918,6 +918,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
const FutureMergedMutatedPart & future_part,
const std::vector<MutationCommand> & commands,
MergeListEntry & merge_entry,
time_t time_of_mutation,
const Context & context,
const ReservationPtr & space_reservation,
TableStructureReadLockHolder & table_lock_holder)
@ -1025,7 +1026,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
std::make_shared<ExpressionBlockInputStream>(in, data.primary_key_and_skip_indices_expr));
if (need_remove_expired_values)
in = std::make_shared<TTLBlockInputStream>(in, data, new_data_part, time(nullptr), true);
in = std::make_shared<TTLBlockInputStream>(in, data, new_data_part, time_of_mutation, true);
MergeTreeDataPart::MinMaxIndex minmax_idx;
@ -1133,7 +1134,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataMergerMutator::mutatePartToTempor
merge_entry->columns_written = all_columns.size() - updated_header.columns();
if (need_remove_expired_values)
in = std::make_shared<TTLBlockInputStream>(in, data, new_data_part, time(nullptr), true);
in = std::make_shared<TTLBlockInputStream>(in, data, new_data_part, time_of_mutation, true);
IMergedBlockOutputStream::WrittenOffsetColumns unused_written_offsets;
MergedColumnOnlyOutputStream out(

View File

@ -105,7 +105,9 @@ public:
MergeTreeData::MutableDataPartPtr mutatePartToTemporaryPart(
const FutureMergedMutatedPart & future_part,
const std::vector<MutationCommand> & commands,
MergeListEntry & merge_entry, const Context & context,
MergeListEntry & merge_entry,
time_t time_of_mutation,
const Context & context,
const ReservationPtr & disk_reservation,
TableStructureReadLockHolder & table_lock_holder);

View File

@ -785,8 +785,8 @@ bool StorageMergeTree::tryMutatePart()
try
{
new_part = merger_mutator.mutatePartToTemporaryPart(future_part, commands, *merge_entry, global_context,
tagger->reserved_space, table_lock_holder);
new_part = merger_mutator.mutatePartToTemporaryPart(future_part, commands, *merge_entry,
time(nullptr), global_context, tagger->reserved_space, table_lock_holder);
renameTempPartAndReplace(new_part);
removeEmptyColumnsFromPart(new_part);

View File

@ -1237,7 +1237,7 @@ bool StorageReplicatedMergeTree::tryExecutePartMutation(const StorageReplicatedM
try
{
new_part = merger_mutator.mutatePartToTemporaryPart(future_mutated_part, commands, *merge_entry, global_context, reserved_space, table_lock);
new_part = merger_mutator.mutatePartToTemporaryPart(future_mutated_part, commands, *merge_entry, entry.create_time, global_context, reserved_space, table_lock);
renameTempPartAndReplace(new_part, nullptr, &transaction);
removeEmptyColumnsFromPart(new_part);

View File

@ -30,7 +30,7 @@ select count() from ttl where s = 'b';
drop table ttl;
-- check only that it doesn't throws exceptions.
-- check only that it doesn't throw exceptions.
create table ttl (i Int, s String) engine = MergeTree order by i ttl toDate('2000-01-01') TO DISK 'default';
alter table ttl materialize ttl;
drop table ttl;