2018-02-25 00:50:53 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Core/QueryProcessingStage.h>
|
2020-11-01 13:54:07 +00:00
|
|
|
#include <Interpreters/IInterpreterUnionOrSelectQuery.h>
|
2018-02-25 00:50:53 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class InterpreterSelectQuery;
|
2020-06-18 17:45:00 +00:00
|
|
|
class QueryPlan;
|
2018-02-25 00:50:53 +00:00
|
|
|
|
2020-10-24 13:18:04 +00:00
|
|
|
/** Interprets one or multiple SELECT queries inside UNION/UNION ALL/UNION DISTINCT chain.
|
2018-02-25 00:50:53 +00:00
|
|
|
*/
|
2020-11-01 13:54:07 +00:00
|
|
|
class InterpreterSelectWithUnionQuery : public IInterpreterUnionOrSelectQuery
|
2018-02-25 00:50:53 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-11-01 13:54:07 +00:00
|
|
|
using IInterpreterUnionOrSelectQuery::getSampleBlock;
|
|
|
|
|
2018-02-25 00:50:53 +00:00
|
|
|
InterpreterSelectWithUnionQuery(
|
|
|
|
const ASTPtr & query_ptr_,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr 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
|
|
|
|
2020-06-18 17:45:00 +00:00
|
|
|
/// Builds QueryPlan for current query.
|
2020-11-01 13:54:07 +00:00
|
|
|
virtual void buildQueryPlan(QueryPlan & query_plan) override;
|
2020-06-18 17:45:00 +00:00
|
|
|
|
2018-02-25 00:50:53 +00:00
|
|
|
BlockIO execute() override;
|
|
|
|
|
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
|
|
|
static Block getSampleBlock(
|
|
|
|
const ASTPtr & query_ptr_,
|
2021-04-10 23:33:54 +00:00
|
|
|
ContextPtr context_,
|
2021-02-14 06:20:23 +00:00
|
|
|
bool is_subquery = false);
|
2018-02-25 00:50:53 +00:00
|
|
|
|
2020-11-01 13:54:07 +00:00
|
|
|
virtual void ignoreWithTotals() override;
|
2019-02-11 19:53:55 +00:00
|
|
|
|
2018-02-25 00:50:53 +00:00
|
|
|
private:
|
2020-11-01 13:54:07 +00:00
|
|
|
std::vector<std::unique_ptr<IInterpreterUnionOrSelectQuery>> nested_interpreters;
|
2018-02-26 06:12:59 +00:00
|
|
|
|
2020-11-01 13:54:07 +00:00
|
|
|
static Block getCommonHeaderForUnion(const Blocks & headers);
|
2019-04-09 13:07:07 +00:00
|
|
|
|
2020-11-01 13:54:07 +00:00
|
|
|
Block getCurrentChildResultHeader(const ASTPtr & ast_ptr_, const Names & required_result_column_names);
|
2020-03-16 18:45:39 +00:00
|
|
|
|
2020-11-01 13:54:07 +00:00
|
|
|
std::unique_ptr<IInterpreterUnionOrSelectQuery>
|
|
|
|
buildCurrentChildInterpreter(const ASTPtr & ast_ptr_, const Names & current_required_result_column_names);
|
2018-02-25 00:50:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|