Better UNION ALL: development #1947

This commit is contained in:
Alexey Milovidov 2018-02-26 12:10:11 +03:00
parent ac37b89b16
commit 44d0736138
2 changed files with 6 additions and 6 deletions

View File

@ -913,7 +913,7 @@ StoragePtr ExpressionAnalyzer::getTable()
auto select_table = select->table(); auto select_table = select->table();
if (select_table if (select_table
&& !typeid_cast<const ASTSelectQuery *>(select_table.get()) && !typeid_cast<const ASTSelectWithUnionQuery *>(select_table.get())
&& !typeid_cast<const ASTFunction *>(select_table.get())) && !typeid_cast<const ASTFunction *>(select_table.get()))
{ {
String database = select_database String database = select_database

View File

@ -135,6 +135,11 @@ BlockInputStreams InterpreterSelectWithUnionQuery::executeWithMultipleStreams()
nested_streams.insert(nested_streams.end(), streams.begin(), streams.end()); nested_streams.insert(nested_streams.end(), streams.begin(), streams.end());
} }
/// Unify data structure.
if (nested_interpreters.size() > 1)
for (auto & stream : nested_streams)
stream = std::make_shared<ConvertingBlockInputStream>(context, stream, result_header, ConvertingBlockInputStream::MatchColumnsMode::Position);
return nested_streams; return nested_streams;
} }
@ -155,11 +160,6 @@ BlockIO InterpreterSelectWithUnionQuery::execute()
} }
else else
{ {
/// Unify data structure.
if (nested_interpreters.size() > 1)
for (auto & stream : nested_streams)
stream = std::make_shared<ConvertingBlockInputStream>(context, stream, result_header, ConvertingBlockInputStream::MatchColumnsMode::Position);
result_stream = std::make_shared<UnionBlockInputStream<>>(nested_streams, nullptr, context.getSettingsRef().max_threads); result_stream = std::make_shared<UnionBlockInputStream<>>(nested_streams, nullptr, context.getSettingsRef().max_threads);
nested_streams.clear(); nested_streams.clear();
} }