This commit is contained in:
Nikita Mikhaylov 2023-09-29 11:16:24 +00:00
parent a5ecdf7436
commit 804ae4c58b
4 changed files with 17 additions and 7 deletions

View File

@ -8280,15 +8280,28 @@ MovePartsOutcome MergeTreeData::moveParts(const CurrentlyMovingPartsTaggerPtr &
return result;
}
bool MergeTreeData::partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right)
bool MergeTreeData::partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right, String & out_reason)
{
if (left->getProjectionParts().size() != right->getProjectionParts().size())
{
out_reason = fmt::format(
"Parts have different number of projections: {} in one part and {} in another",
left->getProjectionParts().size(),
right->getProjectionParts().size()
);
return false;
}
for (const auto & [name, _] : left->getProjectionParts())
{
if (!right->hasProjection(name))
{
out_reason = fmt::format(
"Some part doesn't have projection '{}' while another does", name
)
return false;
}
}
return true;
}

View File

@ -425,7 +425,7 @@ public:
static ReservationPtr tryReserveSpace(UInt64 expected_size, const IDataPartStorage & data_part_storage);
static ReservationPtr reserveSpace(UInt64 expected_size, const IDataPartStorage & data_part_storage);
static bool partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right);
static bool partsContainSameProjections(const DataPartPtr & left, const DataPartPtr & right, String & out_reason);
StoragePolicyPtr getStoragePolicy() const override;

View File

@ -2403,7 +2403,7 @@ bool BaseMergePredicate<VirtualPartsT, MutationsStateT>::canMergeTwoParts(
}
}
return MergeTreeData::partsContainSameProjections(left, right);
return MergeTreeData::partsContainSameProjections(left, right, out_reason);
}
template<typename VirtualPartsT, typename MutationsStateT>

View File

@ -932,11 +932,8 @@ MergeMutateSelectedEntryPtr StorageMergeTree::selectPartsToMerge(
return false;
}
if (!partsContainSameProjections(left, right))
{
disable_reason = "Some parts contains differ projections";
if (!partsContainSameProjections(left, right, disable_reason))
return false;
}
auto max_possible_level = getMaxLevelInBetween(left, right);
if (max_possible_level > std::max(left->info.level, right->info.level))