diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index 4bfabf65f1e..e76c70eb6bb 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -95,7 +95,6 @@ #include #include #include -#include namespace DB @@ -1951,7 +1950,7 @@ void InterpreterSelectQuery::executeAggregation(QueryPipeline & pipeline, const if (pipeline.getNumStreams() > 1) { /// Add resize transform to uniformly distribute data between aggregating streams. - if (!(storage && typeid_cast(storage.get()))) + if (!(storage && storage->hasEvenlyDistributedRead())) pipeline.resize(pipeline.getNumStreams(), true, true); auto many_data = std::make_shared(pipeline.getNumStreams()); diff --git a/dbms/src/Storages/IStorage.h b/dbms/src/Storages/IStorage.h index 69bbca86879..0fe11b1c7e8 100644 --- a/dbms/src/Storages/IStorage.h +++ b/dbms/src/Storages/IStorage.h @@ -113,6 +113,8 @@ public: /// Returns true if the blocks shouldn't be pushed to associated views on insert. virtual bool noPushingToViews() const { return false; } + virtual bool hasEvenlyDistributedRead() const { return false; } + /// Optional size information of each physical column. /// Currently it's only used by the MergeTree family for query optimizations. using ColumnSizeByName = std::unordered_map; diff --git a/dbms/src/Storages/System/StorageSystemNumbers.h b/dbms/src/Storages/System/StorageSystemNumbers.h index 76070839012..911a8ad0081 100644 --- a/dbms/src/Storages/System/StorageSystemNumbers.h +++ b/dbms/src/Storages/System/StorageSystemNumbers.h @@ -39,6 +39,8 @@ public: size_t max_block_size, unsigned num_streams) override; + bool hasEvenlyDistributedRead() const override { return true; } + private: const std::string name; bool multithreaded;