2022-07-14 11:20:16 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Interpreters/IInterpreter.h>
|
|
|
|
#include <Interpreters/SelectQueryOptions.h>
|
|
|
|
|
2022-12-23 17:45:28 +00:00
|
|
|
#include <Analyzer/QueryTreePassManager.h>
|
2022-08-24 09:21:03 +00:00
|
|
|
#include <Planner/Planner.h>
|
2022-12-23 17:45:28 +00:00
|
|
|
#include <Interpreters/Context_fwd.h>
|
2022-08-24 09:21:03 +00:00
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2022-12-06 09:44:38 +00:00
|
|
|
class InterpreterSelectQueryAnalyzer : public IInterpreter
|
2022-07-14 11:20:16 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-07-18 17:20:28 +00:00
|
|
|
/// Initialize interpreter with query AST
|
2022-08-24 09:21:03 +00:00
|
|
|
InterpreterSelectQueryAnalyzer(const ASTPtr & query_,
|
2022-12-23 17:45:28 +00:00
|
|
|
const ContextPtr & context_,
|
|
|
|
const SelectQueryOptions & select_query_options_);
|
2022-07-14 11:20:16 +00:00
|
|
|
|
2023-02-11 11:10:53 +00:00
|
|
|
/** Initialize interpreter with query AST and storage.
|
|
|
|
* After query tree is built left most table expression is replaced with table node that
|
|
|
|
* is initialized with provided storage.
|
|
|
|
*/
|
|
|
|
InterpreterSelectQueryAnalyzer(const ASTPtr & query_,
|
|
|
|
const ContextPtr & context_,
|
2023-02-18 16:06:00 +00:00
|
|
|
const StoragePtr & storage_,
|
|
|
|
const SelectQueryOptions & select_query_options_);
|
2023-02-11 11:10:53 +00:00
|
|
|
|
2022-08-31 15:21:17 +00:00
|
|
|
/// Initialize interpreter with query tree
|
|
|
|
InterpreterSelectQueryAnalyzer(const QueryTreeNodePtr & query_tree_,
|
2022-12-23 17:45:28 +00:00
|
|
|
const ContextPtr & context_,
|
|
|
|
const SelectQueryOptions & select_query_options_);
|
2022-08-31 15:21:17 +00:00
|
|
|
|
2022-12-23 17:45:28 +00:00
|
|
|
ContextPtr getContext() const
|
2022-12-06 09:44:38 +00:00
|
|
|
{
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
Block getSampleBlock();
|
|
|
|
|
2023-01-26 10:52:40 +00:00
|
|
|
static Block getSampleBlock(const ASTPtr & query,
|
|
|
|
const ContextPtr & context,
|
|
|
|
const SelectQueryOptions & select_query_options = {});
|
|
|
|
|
2023-02-18 16:06:00 +00:00
|
|
|
static Block getSampleBlock(const QueryTreeNodePtr & query_tree,
|
2023-01-26 10:52:40 +00:00
|
|
|
const ContextPtr & context_,
|
|
|
|
const SelectQueryOptions & select_query_options = {});
|
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
BlockIO execute() override;
|
|
|
|
|
2023-03-04 17:46:40 +00:00
|
|
|
QueryPlan & getQueryPlan();
|
|
|
|
|
2022-10-12 11:26:02 +00:00
|
|
|
QueryPlan && extractQueryPlan() &&;
|
|
|
|
|
2023-01-20 11:19:16 +00:00
|
|
|
QueryPipelineBuilder buildQueryPipeline();
|
2022-12-15 12:03:09 +00:00
|
|
|
|
2022-12-14 17:43:49 +00:00
|
|
|
void addStorageLimits(const StorageLimitsList & storage_limits);
|
|
|
|
|
2023-11-09 15:13:57 +00:00
|
|
|
void extendQueryLogElemImpl(QueryLogElement & elem, const ASTPtr & /*ast*/, ContextPtr /*context*/) const override;
|
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
bool supportsTransactions() const override { return true; }
|
|
|
|
|
2022-10-12 11:26:02 +00:00
|
|
|
bool ignoreLimits() const override { return select_query_options.ignore_limits; }
|
|
|
|
|
|
|
|
bool ignoreQuota() const override { return select_query_options.ignore_quota; }
|
|
|
|
|
2023-03-23 15:53:22 +00:00
|
|
|
const Planner & getPlanner() const { return planner; }
|
2023-11-09 15:13:57 +00:00
|
|
|
|
2023-04-02 08:09:39 +00:00
|
|
|
Planner & getPlanner() { return planner; }
|
2023-03-07 20:39:26 +00:00
|
|
|
|
2023-06-14 18:10:30 +00:00
|
|
|
const QueryTreeNodePtr & getQueryTree() const { return query_tree; }
|
|
|
|
|
2022-08-15 16:34:10 +00:00
|
|
|
private:
|
2022-07-18 17:20:28 +00:00
|
|
|
ASTPtr query;
|
2022-12-23 17:45:28 +00:00
|
|
|
ContextMutablePtr context;
|
2022-07-14 11:20:16 +00:00
|
|
|
SelectQueryOptions select_query_options;
|
2022-12-23 17:45:28 +00:00
|
|
|
QueryTreeNodePtr query_tree;
|
2022-08-24 09:21:03 +00:00
|
|
|
Planner planner;
|
2022-07-14 11:20:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|