2018-02-25 00:50:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/QueryProcessingStage.h>
|
|
|
|
#include <Interpreters/Context.h>
|
|
|
|
#include <Interpreters/IInterpreter.h>
|
2019-03-15 13:49:58 +00:00
|
|
|
#include <Interpreters/SelectQueryOptions.h>
|
2018-02-25 00:50:53 +00:00
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
#include <Processors/QueryPipeline.h>
|
2018-02-25 00:50:53 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class InterpreterSelectQuery;
|
|
|
|
|
|
|
|
|
|
|
|
/** Interprets one or multiple SELECT queries inside UNION ALL chain.
|
|
|
|
*/
|
|
|
|
class InterpreterSelectWithUnionQuery : public IInterpreter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InterpreterSelectWithUnionQuery(
|
|
|
|
const ASTPtr & query_ptr_,
|
|
|
|
const Context & context_,
|
2019-03-15 13:49:58 +00:00
|
|
|
const SelectQueryOptions &,
|
|
|
|
const Names & required_result_column_names = {});
|
2018-02-25 00:50:53 +00:00
|
|
|
|
2018-08-10 04:02:56 +00:00
|
|
|
~InterpreterSelectWithUnionQuery() override;
|
2018-02-25 00:50:53 +00:00
|
|
|
|
|
|
|
BlockIO execute() override;
|
|
|
|
|
|
|
|
/// Execute the query without union of streams.
|
2019-11-15 18:41:18 +00:00
|
|
|
BlockInputStreams executeWithMultipleStreams(QueryPipeline & parent_pipeline);
|
2018-02-25 00:50:53 +00:00
|
|
|
|
2019-03-26 18:28:37 +00:00
|
|
|
QueryPipeline executeWithProcessors() override;
|
|
|
|
bool canExecuteWithProcessors() const override { return true; }
|
|
|
|
|
2019-11-11 01:11:32 +00:00
|
|
|
bool ignoreLimits() const override { return options.ignore_limits; }
|
|
|
|
bool ignoreQuota() const override { return options.ignore_quota; }
|
|
|
|
|
2018-02-25 00:50:53 +00:00
|
|
|
Block getSampleBlock();
|
|
|
|
|
|
|
|
static Block getSampleBlock(
|
|
|
|
const ASTPtr & query_ptr_,
|
|
|
|
const Context & context_);
|
|
|
|
|
2018-02-25 06:34:20 +00:00
|
|
|
void ignoreWithTotals();
|
|
|
|
|
2019-02-11 19:53:55 +00:00
|
|
|
ASTPtr getQuery() const { return query_ptr; }
|
|
|
|
|
2018-02-25 00:50:53 +00:00
|
|
|
private:
|
2019-11-11 01:11:32 +00:00
|
|
|
SelectQueryOptions options;
|
2018-02-25 00:50:53 +00:00
|
|
|
ASTPtr query_ptr;
|
2019-11-18 16:13:43 +00:00
|
|
|
std::shared_ptr<Context> context;
|
2018-02-25 00:50:53 +00:00
|
|
|
|
|
|
|
std::vector<std::unique_ptr<InterpreterSelectQuery>> nested_interpreters;
|
2018-02-26 06:12:59 +00:00
|
|
|
|
|
|
|
Block result_header;
|
2019-04-09 13:07:07 +00:00
|
|
|
|
2020-03-16 18:45:39 +00:00
|
|
|
size_t max_streams = 1;
|
|
|
|
|
2019-04-09 13:07:07 +00:00
|
|
|
static Block getCommonHeaderForUnion(const Blocks & headers);
|
2018-02-25 00:50:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|