Fix Merge(Distributed()) with JOIN

This commit is contained in:
Azat Khuzhin 2020-11-14 01:56:25 +03:00
parent 4a77a42f34
commit 5297417050

View File

@ -134,6 +134,18 @@ bool StorageMerge::mayBenefitFromIndexForIn(const ASTPtr & left_in_operand, cons
QueryProcessingStage::Enum StorageMerge::getQueryProcessingStage(const Context & context, QueryProcessingStage::Enum to_stage, SelectQueryInfo & query_info) const
{
ASTPtr modified_query = query_info.query->clone();
auto & modified_select = modified_query->as<ASTSelectQuery &>();
/// In case of JOIN the first stage (which includes JOIN)
/// should be done on the initiator always.
///
/// Since in case of JOIN query on shards will receive query w/o JOIN (and their columns).
/// (see modifySelect()/removeJoin())
///
/// And for this we need to return FetchColumns.
if (removeJoin(modified_select))
return QueryProcessingStage::FetchColumns;
auto stage_in_source_tables = QueryProcessingStage::FetchColumns;
DatabaseTablesIteratorPtr iterator = getDatabaseIterator(context);