From 1011675b11149d1cbe6be31b8238e302e7246740 Mon Sep 17 00:00:00 2001 From: CurtizJ Date: Mon, 13 Jan 2020 19:28:29 +0300 Subject: [PATCH] avoid errors with compact non-adaptive parts --- dbms/src/Storages/MergeTree/MergeTreeData.cpp | 30 ++++++++++++++++++- dbms/src/Storages/MergeTree/MergeTreeData.h | 2 ++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/dbms/src/Storages/MergeTree/MergeTreeData.cpp b/dbms/src/Storages/MergeTree/MergeTreeData.cpp index 4f7c11130d7..37b5d07c5b6 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeData.cpp +++ b/dbms/src/Storages/MergeTree/MergeTreeData.cpp @@ -237,6 +237,8 @@ MergeTreeData::MergeTreeData( "MergeTree data format version on disk doesn't support custom partitioning", ErrorCodes::METADATA_MISMATCH); } + + checkCanUsePolymorphicParts(true); } @@ -1567,6 +1569,9 @@ AlterAnalysisResult MergeTreeData::analyzeAlterConversions( MergeTreeDataPartType MergeTreeData::choosePartType(size_t bytes_uncompressed, size_t rows_count) const { + if (!canUseAdaptiveGranularity()) + return MergeTreeDataPartType::WIDE; + const auto settings = getSettings(); if (bytes_uncompressed < settings->min_bytes_for_wide_part || rows_count < settings->min_rows_for_wide_part) return MergeTreeDataPartType::COMPACT; @@ -1584,7 +1589,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeData::createPart(const String & name, else if (type == MergeTreeDataPartType::WIDE) return std::make_shared(*this, name, part_info, disk, relative_path); else - throw Exception("Unknown part type", ErrorCodes::LOGICAL_ERROR); + throw Exception("Unknown type in part " + relative_path, ErrorCodes::UNKNOWN_PART_TYPE); } MergeTreeData::MutableDataPartPtr MergeTreeData::createPart( @@ -1818,6 +1823,7 @@ void MergeTreeData::changeSettings( copy.applyChanges(new_changes); storage_settings.set(std::make_unique(copy)); settings_ast = new_settings; + checkCanUsePolymorphicParts(false); } } @@ -3808,4 +3814,26 @@ bool MergeTreeData::moveParts(CurrentlyMovingPartsTagger && moving_tagger) return true; } +void MergeTreeData::checkCanUsePolymorphicParts(bool no_throw) +{ + const auto settings = getSettings(); + if (!canUseAdaptiveGranularity() && (settings->min_rows_for_wide_part != 0 || settings->min_bytes_for_wide_part != 0)) + { + std::ostringstream message; + message << "Table can't create parts with adaptive granularity, but settings min_rows_for_wide_part = " + << settings->min_rows_for_wide_part << ", min_bytes_for_wide_part = " << settings->min_bytes_for_wide_part + << ". Parts with non-adaptive granularity can be stored only in Wide (default) format."; + + if (no_throw) + { + message << " Settings 'min_bytes_for_wide_part' and 'min_bytes_for_wide_part' will be ignored further."; + LOG_WARNING(log, message.str()); + } + else + { + throw Exception(message.str(), ErrorCodes::NOT_IMPLEMENTED); + } + } +} + } diff --git a/dbms/src/Storages/MergeTree/MergeTreeData.h b/dbms/src/Storages/MergeTree/MergeTreeData.h index 773e7b0f5ef..aef43bb5a2e 100644 --- a/dbms/src/Storages/MergeTree/MergeTreeData.h +++ b/dbms/src/Storages/MergeTree/MergeTreeData.h @@ -1017,6 +1017,8 @@ private: /// Check selected parts for movements. Used by ALTER ... MOVE queries. CurrentlyMovingPartsTagger checkPartsForMove(const DataPartsVector & parts, SpacePtr space); + + void checkCanUsePolymorphicParts(bool no_throw); }; }