ClickHouse/src/Interpreters/InterpreterFactory.h
Bharat Nallan ee37f551a2
independent registration of interpreters (#58443)
* make interpreter factory an instance

* add registerInterpreter

* register interpreters individually

* try wire everything up

* fix style

* fix test
2024-01-08 22:33:48 -08:00

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;
};
}