Properly handle empty parts list

This commit is contained in:
Alexander Gololobov 2022-07-23 01:14:03 +02:00
parent 594195451e
commit be64b45583

View File

@ -9,11 +9,17 @@
#include <Processors/QueryPlan/BuildQueryPipelineSettings.h>
#include <QueryPipeline/QueryPipelineBuilder.h>
#include <Core/Defines.h>
#include <Common/Exception.h>
namespace DB
{
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
}
/// A Storage that allows reading from a single MergeTree data part.
class StorageFromMergeTreeDataPart final : public IStorage
{
@ -103,19 +109,21 @@ public:
bool materializeTTLRecalculateOnly() const
{
if (parts.empty())
throw Exception(ErrorCodes::LOGICAL_ERROR, "parts must not be empty for materializeTTLRecalculateOnly");
return parts.front()->storage.getSettings()->materialize_ttl_recalculate_only;
}
bool hasLightweightDeletedMask() const override
{
return parts.front()->hasLightweightDelete();
return !parts.empty() && parts.front()->hasLightweightDelete();
}
private:
MergeTreeData::DataPartsVector parts;
const MergeTreeData::DataPartsVector parts;
const MergeTreeData & storage;
String partition_id;
MergeTreeDataSelectAnalysisResultPtr analysis_result_ptr;
const String partition_id;
const MergeTreeDataSelectAnalysisResultPtr analysis_result_ptr;
static StorageID getIDFromPart(const MergeTreeData::DataPartPtr & part_)
{