2020-10-22 06:18:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
#include <Storages/KeyDescription.h>
|
|
|
|
#include <Storages/MergeTree/IMergeTreeDataPart.h>
|
|
|
|
#include <Storages/MergeTree/KeyCondition.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-11-06 03:50:58 +00:00
|
|
|
/// Pruning partitions in verbatim way using KeyCondition
|
2020-10-22 06:18:10 +00:00
|
|
|
class PartitionPruner
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
std::unordered_map<String, bool> partition_filter_map;
|
|
|
|
const KeyDescription & partition_key;
|
|
|
|
KeyCondition partition_condition;
|
|
|
|
bool useless;
|
|
|
|
using DataPart = IMergeTreeDataPart;
|
|
|
|
using DataPartPtr = std::shared_ptr<const DataPart>;
|
|
|
|
|
|
|
|
public:
|
2020-11-06 11:18:42 +00:00
|
|
|
PartitionPruner(const KeyDescription & partition_key_, const SelectQueryInfo & query_info, const Context & context, bool strict)
|
2020-10-22 06:18:10 +00:00
|
|
|
: partition_key(partition_key_)
|
|
|
|
, partition_condition(
|
2020-11-06 11:18:42 +00:00
|
|
|
query_info, context, partition_key.column_names, partition_key.expression, true /* single_point */, strict)
|
2020-10-22 06:18:10 +00:00
|
|
|
, useless(partition_condition.alwaysUnknownOrTrue())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-11-06 03:50:58 +00:00
|
|
|
bool canBePruned(const DataPartPtr & part);
|
2020-10-22 06:18:10 +00:00
|
|
|
|
|
|
|
bool isUseless() const { return useless; }
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|