Preparation: Storages do not modify query [#CLICKHOUSE-31].

This commit is contained in:
Alexey Milovidov 2017-05-25 04:12:41 +03:00
parent 6e9fa39af5
commit a77369d082
78 changed files with 131 additions and 144 deletions

View File

@ -18,7 +18,7 @@ namespace DB
class PushingToViewsBlockOutputStream : public IBlockOutputStream
{
public:
PushingToViewsBlockOutputStream(String database, String table, const Context & context_, ASTPtr query_ptr_)
PushingToViewsBlockOutputStream(String database, String table, const Context & context_, const ASTPtr & query_ptr_)
: context(context_), query_ptr(query_ptr_)
{
storage = context.getTable(database, table);

View File

@ -15,7 +15,7 @@ namespace ClusterProxy
{
Query::Query(IQueryConstructor & query_constructor_, const ClusterPtr & cluster_,
ASTPtr query_ast_, const Context & context_, const Settings & settings_, bool enable_shard_multiplexing_)
const ASTPtr & query_ast_, const Context & context_, const Settings & settings_, bool enable_shard_multiplexing_)
: query_constructor{query_constructor_}, cluster{cluster_}, query_ast{query_ast_},
context{context_}, settings{settings_}, enable_shard_multiplexing{enable_shard_multiplexing_}
{

View File

@ -26,7 +26,7 @@ class Query
{
public:
Query(IQueryConstructor & query_constructor_, const ClusterPtr & cluster_,
ASTPtr query_ast_, const Context & context_, const Settings & settings_, bool enable_shard_multiplexing_);
const ASTPtr & query_ast_, const Context & context_, const Settings & settings_, bool enable_shard_multiplexing_);
/// For each location at which we perform the query, create an input stream
/// from which we can fetch the result.

View File

@ -32,8 +32,11 @@
#include <Interpreters/InterpreterSelectQuery.h>
#include <Interpreters/InterpreterSetQuery.h>
#include <Interpreters/ExpressionAnalyzer.h>
#include <Storages/MergeTree/MergeTreeWhereOptimizer.h>
#include <Storages/IStorage.h>
#include <Storages/StorageMergeTree.h>
#include <Storages/StorageReplicatedMergeTree.h>
#include <TableFunctions/ITableFunction.h>
#include <TableFunctions/TableFunctionFactory.h>
@ -844,6 +847,23 @@ QueryProcessingStage::Enum InterpreterSelectQuery::executeFetchColumns()
else
actual_query_ptr = query_ptr;
/// PREWHERE optimization
{
auto optimize_prewhere = [&](auto & merge_tree)
{
const ASTSelectQuery & actual_select = typeid_cast<const ASTSelectQuery &>(*actual_query_ptr);
/// Try transferring some condition from WHERE to PREWHERE if enabled and viable
if (settings.optimize_move_to_prewhere && actual_select.where_expression && !actual_select.prewhere_expression && !actual_select.final())
MergeTreeWhereOptimizer{actual_query_ptr, context, merge_tree.getData(), required_columns, log};
};
if (const StorageMergeTree * merge_tree = typeid_cast<const StorageMergeTree *>(storage.get()))
optimize_prewhere(*merge_tree);
else if (const StorageReplicatedMergeTree * merge_tree = typeid_cast<const StorageReplicatedMergeTree *>(storage.get()))
optimize_prewhere(*merge_tree);
}
streams = storage->read(required_columns, actual_query_ptr,
context, from_stage, max_block_size, max_streams);

View File

@ -168,7 +168,7 @@ public:
*/
virtual BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
@ -215,21 +215,21 @@ public:
}
/** Execute DROP COLUMN ... FROM PARTITION query witch drops column from given partition. */
virtual void dropColumnFromPartition(ASTPtr query, const Field & partition, const Field & column_name, const Settings & settings)
virtual void dropColumnFromPartition(const ASTPtr & query, const Field & partition, const Field & column_name, const Settings & settings)
{
throw Exception("Method dropColumnFromPartition is not supported by storage " + getName(), ErrorCodes::NOT_IMPLEMENTED);
}
/** Run the query (DROP|DETACH) PARTITION.
*/
virtual void dropPartition(ASTPtr query, const Field & partition, bool detach, const Settings & settings)
virtual void dropPartition(const ASTPtr & query, const Field & partition, bool detach, const Settings & settings)
{
throw Exception("Method dropPartition is not supported by storage " + getName(), ErrorCodes::NOT_IMPLEMENTED);
}
/** Run the ATTACH request (PART|PARTITION).
*/
virtual void attachPartition(ASTPtr query, const Field & partition, bool part, const Settings & settings)
virtual void attachPartition(const ASTPtr & query, const Field & partition, bool part, const Settings & settings)
{
throw Exception("Method attachPartition is not supported by storage " + getName(), ErrorCodes::NOT_IMPLEMENTED);
}
@ -318,9 +318,6 @@ private:
mutable Poco::RWLock structure_lock;
};
using StorageVector = std::vector<StoragePtr>;
using StorageList = std::list<StoragePtr>;
/// table name -> table
using Tables = std::map<String, StoragePtr>;

View File

@ -129,7 +129,7 @@ static RelativeSize convertAbsoluteSampleSizeToRelative(const ASTPtr & node, siz
BlockInputStreams MergeTreeDataSelectExecutor::read(
const Names & column_names_to_return,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -22,7 +22,7 @@ public:
*/
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,

View File

@ -3,6 +3,7 @@
#include <memory>
#include <unordered_map>
#include <set>
#include <boost/noncopyable.hpp>
#include <Core/Block.h>
@ -30,12 +31,9 @@ using IdentifierNameSet = std::set<std::string>;
* Otherwise any condition with minimal summary column size can be transferred to PREWHERE, if only
* its relative size (summary column size divided by query column size) is less than `max_columns_relative_size`.
*/
class MergeTreeWhereOptimizer
class MergeTreeWhereOptimizer : private boost::noncopyable
{
public:
MergeTreeWhereOptimizer(const MergeTreeWhereOptimizer&) = delete;
MergeTreeWhereOptimizer& operator=(const MergeTreeWhereOptimizer&) = delete;
MergeTreeWhereOptimizer(
ASTPtr & query, const Context & context, const MergeTreeData & data, const Names & column_names,
Poco::Logger * log);

View File

@ -100,7 +100,7 @@ const PKCondition::AtomMap PKCondition::atom_map
{
{
"notEquals",
[] (RPNElement & out, const Field & value, ASTPtr &)
[] (RPNElement & out, const Field & value, const ASTPtr &)
{
out.function = RPNElement::FUNCTION_NOT_IN_RANGE;
out.range = Range(value);
@ -109,7 +109,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"equals",
[] (RPNElement & out, const Field & value, ASTPtr &)
[] (RPNElement & out, const Field & value, const ASTPtr &)
{
out.function = RPNElement::FUNCTION_IN_RANGE;
out.range = Range(value);
@ -118,7 +118,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"less",
[] (RPNElement & out, const Field & value, ASTPtr &)
[] (RPNElement & out, const Field & value, const ASTPtr &)
{
out.function = RPNElement::FUNCTION_IN_RANGE;
out.range = Range::createRightBounded(value, false);
@ -127,7 +127,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"greater",
[] (RPNElement & out, const Field & value, ASTPtr &)
[] (RPNElement & out, const Field & value, const ASTPtr &)
{
out.function = RPNElement::FUNCTION_IN_RANGE;
out.range = Range::createLeftBounded(value, false);
@ -136,7 +136,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"lessOrEquals",
[] (RPNElement & out, const Field & value, ASTPtr &)
[] (RPNElement & out, const Field & value, const ASTPtr &)
{
out.function = RPNElement::FUNCTION_IN_RANGE;
out.range = Range::createRightBounded(value, true);
@ -145,7 +145,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"greaterOrEquals",
[] (RPNElement & out, const Field & value, ASTPtr &)
[] (RPNElement & out, const Field & value, const ASTPtr &)
{
out.function = RPNElement::FUNCTION_IN_RANGE;
out.range = Range::createLeftBounded(value, true);
@ -154,7 +154,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"in",
[] (RPNElement & out, const Field &, ASTPtr & node)
[] (RPNElement & out, const Field &, const ASTPtr & node)
{
out.function = RPNElement::FUNCTION_IN_SET;
out.in_function = node;
@ -163,7 +163,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"notIn",
[] (RPNElement & out, const Field &, ASTPtr & node)
[] (RPNElement & out, const Field &, const ASTPtr & node)
{
out.function = RPNElement::FUNCTION_NOT_IN_SET;
out.in_function = node;
@ -172,7 +172,7 @@ const PKCondition::AtomMap PKCondition::atom_map
},
{
"like",
[] (RPNElement & out, const Field & value, ASTPtr & node)
[] (RPNElement & out, const Field & value, const ASTPtr &)
{
if (value.getType() != Field::Types::String)
return false;
@ -218,7 +218,7 @@ Block PKCondition::getBlockWithConstants(
}
PKCondition::PKCondition(ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns,
PKCondition::PKCondition(const ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns,
const SortDescription & sort_descr_, const Block & pk_sample_block_)
: sort_descr(sort_descr_), pk_sample_block(pk_sample_block_)
{
@ -235,7 +235,7 @@ PKCondition::PKCondition(ASTPtr & query, const Context & context, const NamesAnd
Block block_with_constants = getBlockWithConstants(query, context, all_columns);
/// Trasform WHERE section to Reverse Polish notation
ASTSelectQuery & select = typeid_cast<ASTSelectQuery &>(*query);
const ASTSelectQuery & select = typeid_cast<const ASTSelectQuery &>(*query);
if (select.where_expression)
{
traverseAST(select.where_expression, context, block_with_constants);
@ -297,7 +297,7 @@ static bool getConstant(const ASTPtr & expr, Block & block_with_constants, Field
return false;
}
void PKCondition::traverseAST(ASTPtr & node, const Context & context, Block & block_with_constants)
void PKCondition::traverseAST(const ASTPtr & node, const Context & context, Block & block_with_constants)
{
RPNElement element;
@ -417,7 +417,7 @@ static void castValueToType(const DataTypePtr & desired_type, Field & src_value,
}
bool PKCondition::atomFromAST(ASTPtr & node, const Context & context, Block & block_with_constants, RPNElement & out)
bool PKCondition::atomFromAST(const ASTPtr & node, const Context & context, Block & block_with_constants, RPNElement & out)
{
/** Functions < > = != <= >= in `notIn`, where one argument is a constant, and the other is one of columns of primary key,
* or itself, wrapped in a chain of possibly-monotone functions,
@ -576,7 +576,7 @@ static void applyFunction(
* A pair of marks specifies a segment with respect to the order over the tuples.
* Denote it like this: [ x1 y1 z1 .. x2 y2 z2 ],
* where x1 y1 z1 - tuple - value of primary key in left border of segment;
* x2 y2 z2 - tuple - value of primary key in right boundary of segment.
* x2 y2 z2 - tuple - value of primary key in right boundary of segment.
* In this section there are data between these marks.
*
* Or, the last mark specifies the range open on the right: [ a b c .. + inf )
@ -695,7 +695,7 @@ bool PKCondition::mayBeTrueInRange(
{
std::vector<Range> key_ranges(used_key_size, Range());
/* std::cerr << "Checking for: [";
/* std::cerr << "Checking for: [";
for (size_t i = 0; i != used_key_size; ++i)
std::cerr << (i != 0 ? ", " : "") << applyVisitor(FieldVisitorToString(), left_pk[i]);
std::cerr << " ... ";
@ -714,7 +714,7 @@ bool PKCondition::mayBeTrueInRange(
{
auto res = mayBeTrueInRangeImpl(key_ranges, data_types);
/* std::cerr << "Parallelogram: ";
/* std::cerr << "Parallelogram: ";
for (size_t i = 0, size = key_ranges.size(); i != size; ++i)
std::cerr << (i != 0 ? " x " : "") << key_ranges[i].toString();
std::cerr << ": " << res << "\n";*/

View File

@ -202,7 +202,7 @@ class PKCondition
{
public:
/// Does not include the SAMPLE section. all_columns - the set of all columns of the table.
PKCondition(ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns, const SortDescription & sort_descr,
PKCondition(const ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns, const SortDescription & sort_descr,
const Block & pk_sample_block);
/// Whether the condition is feasible in the key range.
@ -274,7 +274,7 @@ public:
static Block getBlockWithConstants(
const ASTPtr & query, const Context & context, const NamesAndTypesList & all_columns);
using AtomMap = std::unordered_map<std::string, bool(*)(RPNElement & out, const Field & value, ASTPtr & node)>;
using AtomMap = std::unordered_map<std::string, bool(*)(RPNElement & out, const Field & value, const ASTPtr & node)>;
static const AtomMap atom_map;
private:
@ -290,8 +290,8 @@ private:
bool mayBeTrueInRangeImpl(const std::vector<Range> & key_ranges, const DataTypes & data_types) const;
void traverseAST(ASTPtr & node, const Context & context, Block & block_with_constants);
bool atomFromAST(ASTPtr & node, const Context & context, Block & block_with_constants, RPNElement & out);
void traverseAST(const ASTPtr & node, const Context & context, Block & block_with_constants);
bool atomFromAST(const ASTPtr & node, const Context & context, Block & block_with_constants, RPNElement & out);
bool operatorFromAST(const ASTFunction * func, RPNElement & out);
/** Is node the primary key column

View File

@ -129,7 +129,7 @@ private:
BlockInputStreams StorageBuffer::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,

View File

@ -69,7 +69,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -43,7 +43,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -212,7 +212,7 @@ StoragePtr StorageDistributed::create(
BlockInputStreams StorageDistributed::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -68,7 +68,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -155,7 +155,7 @@ private:
BlockInputStreams StorageFile::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,

View File

@ -74,7 +74,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -802,7 +802,7 @@ const Marks & StorageLog::getMarksWithRealRowCount() const
BlockInputStreams StorageLog::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,

View File

@ -71,7 +71,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
@ -119,18 +119,6 @@ protected:
/// Can be called with any state of `rwlock`.
size_t marksCount();
BlockInputStreams read(
size_t from_mark,
size_t to_mark,
size_t from_null_mark,
const Names & column_names,
ASTPtr query,
const Context & context,
const Settings & settings,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
unsigned threads = 1);
private:
Files_t files; /// name -> data

View File

@ -110,7 +110,7 @@ bool StorageMaterializedView::hasColumn(const String & column_name) const
BlockInputStreams StorageMaterializedView::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -43,7 +43,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -114,7 +114,7 @@ StoragePtr StorageMemory::create(
BlockInputStreams StorageMemory::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,

View File

@ -47,7 +47,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -95,7 +95,7 @@ bool StorageMerge::hasColumn(const String & column_name) const
BlockInputStreams StorageMerge::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,
@ -177,7 +177,7 @@ BlockInputStreams StorageMerge::read(
ErrorCodes::INCOMPATIBLE_SOURCE_TABLES);
/// Subordinary tables could have different but convertible types, like numeric types of different width.
/// We must return streams with structure equals to structure of Merge table.
/// We must return streams with structure equals to structure of Merge table.
for (auto & stream : source_streams)
{
/// will throw if some columns not convertible

View File

@ -49,7 +49,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -4,7 +4,6 @@
#include <Storages/MergeTree/MergeTreeBlockOutputStream.h>
#include <Storages/MergeTree/DiskSpaceMonitor.h>
#include <Storages/MergeTree/MergeList.h>
#include <Storages/MergeTree/MergeTreeWhereOptimizer.h>
#include <Databases/IDatabase.h>
#include <Common/escapeForFileName.h>
#include <Interpreters/InterpreterAlterQuery.h>
@ -107,20 +106,12 @@ StorageMergeTree::~StorageMergeTree()
BlockInputStreams StorageMergeTree::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,
const unsigned threads)
{
auto & select = typeid_cast<const ASTSelectQuery &>(*query);
const Settings & settings = context.getSettingsRef();
/// Try transferring some condition from WHERE to PREWHERE if enabled and viable
if (settings.optimize_move_to_prewhere && select.where_expression && !select.prewhere_expression && !select.final())
MergeTreeWhereOptimizer{query, context, data, column_names, log};
return reader.read(column_names, query, context, processed_stage, max_block_size, threads, nullptr, 0);
}
@ -407,7 +398,7 @@ bool StorageMergeTree::mergeTask()
}
}
void StorageMergeTree::dropColumnFromPartition(ASTPtr query, const Field & partition, const Field & column_name, const Settings &)
void StorageMergeTree::dropColumnFromPartition(const ASTPtr & query, const Field & partition, const Field & column_name, const Settings &)
{
/// Asks to complete merges and does not allow them to start.
/// This protects against "revival" of data for a removed partition after completion of merge.
@ -453,7 +444,7 @@ void StorageMergeTree::dropColumnFromPartition(ASTPtr query, const Field & parti
transaction->commit();
}
void StorageMergeTree::dropPartition(ASTPtr query, const Field & partition, bool detach, const Settings & settings)
void StorageMergeTree::dropPartition(const ASTPtr & query, const Field & partition, bool detach, const Settings & settings)
{
/// Asks to complete merges and does not allow them to start.
/// This protects against "revival" of data for a removed partition after completion of merge.
@ -484,7 +475,7 @@ void StorageMergeTree::dropPartition(ASTPtr query, const Field & partition, bool
}
void StorageMergeTree::attachPartition(ASTPtr query, const Field & field, bool part, const Settings & settings)
void StorageMergeTree::attachPartition(const ASTPtr & query, const Field & field, bool part, const Settings & settings)
{
String partition;

View File

@ -76,7 +76,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
@ -91,9 +91,9 @@ public:
return merge(settings.min_bytes_to_use_direct_io, true, partition, final, deduplicate);
}
void dropPartition(ASTPtr query, const Field & partition, bool detach, const Settings & settings) override;
void dropColumnFromPartition(ASTPtr query, const Field & partition, const Field & column_name, const Settings & settings) override;
void attachPartition(ASTPtr query, const Field & partition, bool part, const Settings & settings) override;
void dropPartition(const ASTPtr & query, const Field & partition, bool detach, const Settings & settings) override;
void dropColumnFromPartition(const ASTPtr & query, const Field & partition, const Field & column_name, const Settings & settings) override;
void attachPartition(const ASTPtr & query, const Field & partition, bool part, const Settings & settings) override;
void freezePartition(const Field & partition, const String & with_name, const Settings & settings) override;
void drop() override;

View File

@ -36,7 +36,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -8,7 +8,6 @@
#include <Storages/MergeTree/ReplicatedMergeTreeBlockOutputStream.h>
#include <Storages/MergeTree/ReplicatedMergeTreeQuorumEntry.h>
#include <Storages/MergeTree/MergeList.h>
#include <Storages/MergeTree/MergeTreeWhereOptimizer.h>
#include <Storages/MergeTree/ReplicatedMergeTreeAddress.h>
#include <Storages/MergeTree/ReshardingWorker.h>
@ -2242,7 +2241,7 @@ StorageReplicatedMergeTree::~StorageReplicatedMergeTree()
BlockInputStreams StorageReplicatedMergeTree::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,
@ -2250,12 +2249,6 @@ BlockInputStreams StorageReplicatedMergeTree::read(
{
const Settings & settings = context.getSettingsRef();
auto & select = typeid_cast<const ASTSelectQuery &>(*query);
/// Try transferring some condition from WHERE to PREWHERE if enabled and viable
if (settings.optimize_move_to_prewhere && select.where_expression && !select.prewhere_expression && !select.final())
MergeTreeWhereOptimizer{query, context, data, column_names, log};
size_t part_index = 0;
/** The `parallel_replica_offset` and `parallel_replicas_count` settings allow you to read one part of the data from one replica, and the other from other replica.
@ -2561,7 +2554,7 @@ static String getFakePartNameForDrop(const String & month_name, UInt64 left, UIn
void StorageReplicatedMergeTree::dropPartition(
ASTPtr query, const Field & field, bool detach, const Settings & settings)
const ASTPtr & query, const Field & field, bool detach, const Settings & settings)
{
assertNotReadonly();
@ -2662,7 +2655,7 @@ void StorageReplicatedMergeTree::dropPartition(
}
void StorageReplicatedMergeTree::attachPartition(ASTPtr query, const Field & field, bool attach_part, const Settings & settings)
void StorageReplicatedMergeTree::attachPartition(const ASTPtr & query, const Field & field, bool attach_part, const Settings & settings)
{
assertNotReadonly();

View File

@ -122,7 +122,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,
@ -134,8 +134,8 @@ public:
void alter(const AlterCommands & params, const String & database_name, const String & table_name, const Context & context) override;
void dropPartition(ASTPtr query, const Field & partition, bool detach, const Settings & settings) override;
void attachPartition(ASTPtr query, const Field & partition, bool part, const Settings & settings) override;
void dropPartition(const ASTPtr & query, const Field & partition, bool detach, const Settings & settings) override;
void attachPartition(const ASTPtr & query, const Field & partition, bool part, const Settings & settings) override;
void fetchPartition(const Field & partition, const String & from, const Settings & settings) override;
void freezePartition(const Field & partition, const String & with_name, const Settings & settings) override;

View File

@ -239,7 +239,7 @@ void StorageStripeLog::rename(const String & new_path_to_db, const String & new_
BlockInputStreams StorageStripeLog::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -46,7 +46,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -543,7 +543,7 @@ void StorageTinyLog::rename(const String & new_path_to_db, const String & new_da
BlockInputStreams StorageTinyLog::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -46,7 +46,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -129,7 +129,7 @@ private:
BlockInputStreams StorageTrivialBuffer::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,

View File

@ -61,7 +61,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -93,7 +93,7 @@ void StorageView::extractDependentTable(const ASTSelectQuery & query)
BlockInputStreams StorageView::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -37,7 +37,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -31,7 +31,7 @@ StoragePtr StorageSystemAsynchronousMetrics::create(const std::string & name_, c
BlockInputStreams StorageSystemAsynchronousMetrics::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -27,7 +27,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -27,7 +27,7 @@ StoragePtr StorageSystemBuildOptions::create(const std::string & name_)
BlockInputStreams StorageSystemBuildOptions::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -36,7 +36,7 @@ StoragePtr StorageSystemClusters::create(const std::string & name_, Context & co
BlockInputStreams StorageSystemClusters::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context_,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -27,7 +27,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -38,7 +38,7 @@ StoragePtr StorageSystemColumns::create(const std::string & name_)
BlockInputStreams StorageSystemColumns::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -23,7 +23,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -28,7 +28,7 @@ StoragePtr StorageSystemDatabases::create(const std::string & name_)
BlockInputStreams StorageSystemDatabases::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -46,7 +46,7 @@ StoragePtr StorageSystemDictionaries::create(const std::string & name)
BlockInputStreams StorageSystemDictionaries::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -22,7 +22,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -28,7 +28,7 @@ StoragePtr StorageSystemEvents::create(const std::string & name_)
BlockInputStreams StorageSystemEvents::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -29,7 +29,7 @@ StoragePtr StorageSystemFunctions::create(const std::string & name_)
BlockInputStreams StorageSystemFunctions::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -131,7 +131,7 @@ StoragePtr StorageSystemGraphite::create(const std::string & name_)
BlockInputStreams StorageSystemGraphite::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size,

View File

@ -22,7 +22,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -41,7 +41,7 @@ StoragePtr StorageSystemMerges::create(const std::string & name)
BlockInputStreams StorageSystemMerges::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -23,7 +23,7 @@ public:
const NamesAndTypesList & getColumnsListImpl() const override { return columns; }
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -29,7 +29,7 @@ StoragePtr StorageSystemMetrics::create(const std::string & name_)
BlockInputStreams StorageSystemMetrics::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -61,7 +61,7 @@ StoragePtr StorageSystemNumbers::create(const std::string & name_, bool multithr
BlockInputStreams StorageSystemNumbers::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -28,7 +28,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -23,7 +23,7 @@ StoragePtr StorageSystemOne::create(const std::string & name_)
BlockInputStreams StorageSystemOne::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -29,7 +29,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -51,7 +51,7 @@ StoragePtr StorageSystemParts::create(const std::string & name_)
BlockInputStreams StorageSystemParts::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -25,7 +25,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -60,7 +60,7 @@ StoragePtr StorageSystemProcesses::create(const std::string & name_)
BlockInputStreams StorageSystemProcesses::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -54,7 +54,7 @@ StoragePtr StorageSystemReplicas::create(const std::string & name_)
BlockInputStreams StorageSystemReplicas::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -54,7 +54,7 @@ StoragePtr StorageSystemReplicationQueue::create(const std::string & name_)
BlockInputStreams StorageSystemReplicationQueue::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -29,7 +29,7 @@ StoragePtr StorageSystemSettings::create(const std::string & name_)
BlockInputStreams StorageSystemSettings::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -36,7 +36,7 @@ StoragePtr StorageSystemTables::create(const std::string & name_)
}
static ColumnWithTypeAndName getFilteredDatabases(ASTPtr query, const Context & context)
static ColumnWithTypeAndName getFilteredDatabases(const ASTPtr & query, const Context & context)
{
ColumnWithTypeAndName column;
column.name = "database";
@ -57,7 +57,7 @@ static ColumnWithTypeAndName getFilteredDatabases(ASTPtr query, const Context &
BlockInputStreams StorageSystemTables::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,

View File

@ -109,7 +109,7 @@ static String extractPath(const ASTPtr & query)
BlockInputStreams StorageSystemZooKeeper::read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
const size_t max_block_size,

View File

@ -26,7 +26,7 @@ public:
BlockInputStreams read(
const Names & column_names,
ASTPtr query,
const ASTPtr & query,
const Context & context,
QueryProcessingStage::Enum & processed_stage,
size_t max_block_size = DEFAULT_BLOCK_SIZE,