mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
ee37f551a2
* make interpreter factory an instance * add registerInterpreter * register interpreters individually * try wire everything up * fix style * fix test
45 lines
948 B
C++
45 lines
948 B
C++
#pragma once
|
|
|
|
#include <Core/QueryProcessingStage.h>
|
|
#include <Interpreters/IInterpreter.h>
|
|
#include <Interpreters/SelectQueryOptions.h>
|
|
#include <Parsers/IAST_fwd.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class Context;
|
|
|
|
class InterpreterFactory : private boost::noncopyable
|
|
{
|
|
public:
|
|
static InterpreterFactory & instance();
|
|
|
|
struct Arguments
|
|
{
|
|
ASTPtr & query;
|
|
ContextMutablePtr context;
|
|
const SelectQueryOptions & options;
|
|
bool allow_materialized;
|
|
};
|
|
|
|
using InterpreterPtr = std::unique_ptr<IInterpreter>;
|
|
|
|
InterpreterPtr get(
|
|
ASTPtr & query,
|
|
ContextMutablePtr context,
|
|
const SelectQueryOptions & options = {});
|
|
|
|
using CreatorFn = std::function<InterpreterPtr(const Arguments & arguments)>;
|
|
|
|
using Interpreters = std::unordered_map<String, CreatorFn>;
|
|
|
|
void registerInterpreter(const std::string & name, CreatorFn creator_fn);
|
|
|
|
private:
|
|
Interpreters interpreters;
|
|
};
|
|
|
|
}
|