| 1 | #pragma once | 
|---|---|
| 2 | |
| 3 | #include <Core/QueryProcessingStage.h> | 
| 4 | #include <Interpreters/Context.h> | 
| 5 | #include <Interpreters/IInterpreter.h> | 
| 6 | #include <Interpreters/SelectQueryOptions.h> | 
| 7 | |
| 8 | #include <Processors/QueryPipeline.h> | 
| 9 | |
| 10 | namespace DB | 
| 11 | { | 
| 12 | |
| 13 | class InterpreterSelectQuery; | 
| 14 | |
| 15 | |
| 16 | /** Interprets one or multiple SELECT queries inside UNION ALL chain. | 
| 17 | */ | 
| 18 | class InterpreterSelectWithUnionQuery : public IInterpreter | 
| 19 | { | 
| 20 | public: | 
| 21 | InterpreterSelectWithUnionQuery( | 
| 22 | const ASTPtr & query_ptr_, | 
| 23 | const Context & context_, | 
| 24 | const SelectQueryOptions &, | 
| 25 | const Names & required_result_column_names = {}); | 
| 26 | |
| 27 | ~InterpreterSelectWithUnionQuery() override; | 
| 28 | |
| 29 | BlockIO execute() override; | 
| 30 | |
| 31 | /// Execute the query without union of streams. | 
| 32 | BlockInputStreams executeWithMultipleStreams(QueryPipeline & parent_pipeline); | 
| 33 | |
| 34 | QueryPipeline executeWithProcessors() override; | 
| 35 | bool canExecuteWithProcessors() const override { return true; } | 
| 36 | |
| 37 | bool ignoreLimits() const override { return options.ignore_limits; } | 
| 38 | bool ignoreQuota() const override { return options.ignore_quota; } | 
| 39 | |
| 40 | Block getSampleBlock(); | 
| 41 | |
| 42 | static Block getSampleBlock( | 
| 43 | const ASTPtr & query_ptr_, | 
| 44 | const Context & context_); | 
| 45 | |
| 46 | void ignoreWithTotals(); | 
| 47 | |
| 48 | ASTPtr getQuery() const { return query_ptr; } | 
| 49 | |
| 50 | private: | 
| 51 | SelectQueryOptions options; | 
| 52 | ASTPtr query_ptr; | 
| 53 | std::shared_ptr<Context> context; | 
| 54 | |
| 55 | std::vector<std::unique_ptr<InterpreterSelectQuery>> nested_interpreters; | 
| 56 | |
| 57 | Block result_header; | 
| 58 | |
| 59 | static Block getCommonHeaderForUnion(const Blocks & headers); | 
| 60 | }; | 
| 61 | |
| 62 | } | 
| 63 | 
