Fix ARRAY JOIN optimisation when reading from MV.

This commit is contained in:
Nikolai Kochetov 2020-10-07 13:11:58 +03:00
parent 5f7aeddfe5
commit df02573c92
2 changed files with 7 additions and 6 deletions

View File

@ -1114,10 +1114,6 @@ ExpressionActionsPtr ExpressionActions::splitActionsBeforeArrayJoin(const NameSe
input_columns = split_actions->getSampleBlock().getNamesAndTypesList();
input_columns.insert(input_columns.end(), inputs_from_array_join.begin(), inputs_from_array_join.end());
/// Remove not needed columns.
if (!actions.empty())
prependProjectInput();
return split_actions;
}

View File

@ -32,8 +32,13 @@ Pipe StorageValues::read(
{
metadata_snapshot->check(column_names, getVirtuals(), getStorageID());
Chunk chunk(res_block.getColumns(), res_block.rows());
return Pipe(std::make_shared<SourceFromSingleChunk>(res_block.cloneEmpty(), std::move(chunk)));
/// Get only required columns.
Block block;
for (const auto & name : column_names)
block.insert(res_block.getByName(name));
Chunk chunk(block.getColumns(), block.rows());
return Pipe(std::make_shared<SourceFromSingleChunk>(block.cloneEmpty(), std::move(chunk)));
}
}