Update building sets.

This commit is contained in:
Nikolai Kochetov 2021-01-13 21:37:54 +03:00
parent e2a2ab6f67
commit 871ac3eeb7

View File

@ -53,6 +53,8 @@
#include <IO/Operators.h>
#include <IO/WriteBufferFromString.h>
#include <Processors/Executors/PullingPipelineExecutor.h>
namespace DB
{
@ -318,13 +320,14 @@ void SelectQueryExpressionAnalyzer::tryMakeSetForIndexFromSubquery(const ASTPtr
}
auto interpreter_subquery = interpretSubquery(subquery_or_table_name, context, {}, query_options);
auto stream = interpreter_subquery->execute().getInputStream();
auto io = interpreter_subquery->execute();
PullingPipelineExecutor executor(io.pipeline);
SetPtr set = std::make_shared<Set>(settings.size_limits_for_set, true, context.getSettingsRef().transform_null_in);
set->setHeader(stream->getHeader());
set->setHeader(executor.getHeader());
stream->readPrefix();
while (Block block = stream->read())
Block block;
while (executor.pull(block))
{
/// If the limits have been exceeded, give up and let the default subquery processing actions take place.
if (!set->insertFromBlock(block))
@ -332,7 +335,6 @@ void SelectQueryExpressionAnalyzer::tryMakeSetForIndexFromSubquery(const ASTPtr
}
set->finishInsert();
stream->readSuffix();
prepared_sets[set_key] = std::move(set);
}