2020-06-18 17:45:00 +00:00
|
|
|
#include <Processors/QueryPlan/UnionStep.h>
|
|
|
|
#include <Processors/QueryPipeline.h>
|
|
|
|
#include <Processors/Sources/NullSource.h>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
UnionStep::UnionStep(DataStreams input_streams_, Block result_header, size_t max_threads_)
|
|
|
|
: header(std::move(result_header))
|
|
|
|
, max_threads(max_threads_)
|
|
|
|
{
|
|
|
|
input_streams = std::move(input_streams_);
|
|
|
|
|
2020-06-22 10:18:28 +00:00
|
|
|
if (input_streams.size() == 1)
|
|
|
|
output_stream = input_streams.front();
|
|
|
|
else
|
|
|
|
output_stream = DataStream{.header = header};
|
2020-06-18 17:45:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QueryPipelinePtr UnionStep::updatePipeline(QueryPipelines pipelines)
|
|
|
|
{
|
|
|
|
auto pipeline = std::make_unique<QueryPipeline>();
|
2020-06-25 09:39:17 +00:00
|
|
|
QueryPipelineProcessorsCollector collector(*pipeline, this);
|
|
|
|
|
2020-06-18 17:45:00 +00:00
|
|
|
if (pipelines.empty())
|
|
|
|
{
|
|
|
|
pipeline->init(Pipe(std::make_shared<NullSource>(output_stream->header)));
|
2020-06-25 09:39:17 +00:00
|
|
|
processors = collector.detachProcessors();
|
2020-06-18 17:45:00 +00:00
|
|
|
return pipeline;
|
|
|
|
}
|
|
|
|
|
2020-08-06 12:24:05 +00:00
|
|
|
*pipeline = QueryPipeline::unitePipelines(std::move(pipelines), output_stream->header ,max_threads);
|
2020-06-18 18:45:27 +00:00
|
|
|
|
2020-06-25 09:39:17 +00:00
|
|
|
processors = collector.detachProcessors();
|
2020-06-18 18:45:27 +00:00
|
|
|
return pipeline;
|
2020-06-18 17:45:00 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 09:39:17 +00:00
|
|
|
void UnionStep::describePipeline(FormatSettings & settings) const
|
|
|
|
{
|
|
|
|
IQueryPlanStep::describePipeline(processors, settings);
|
|
|
|
}
|
|
|
|
|
2020-06-18 17:45:00 +00:00
|
|
|
}
|