ClickHouse/dbms/src/TableFunctions/ITableFunction.h

45 lines
1.0 KiB
C++
Raw Normal View History

#pragma once
2019-03-11 14:01:45 +00:00
#include <Parsers/IAST_fwd.h>
#include <Storages/IStorage_fwd.h>
2019-03-11 14:01:45 +00:00
#include <memory>
#include <string>
2019-03-11 14:01:45 +00:00
namespace DB
{
class Context;
2017-04-16 15:00:33 +00:00
/** Interface for table functions.
*
2017-04-16 15:00:33 +00:00
* Table functions are not relevant to other functions.
* The table function can be specified in the FROM section instead of the [db.]Table
* The table function returns a temporary StoragePtr object that is used to execute the query.
*
2017-04-16 15:00:33 +00:00
* Example:
* SELECT count() FROM remote('example01-01-1', merge, hits)
2017-04-16 15:00:33 +00:00
* - go to `example01-01-1`, in `merge` database, `hits` table.
*/
class ITableFunction
{
public:
2017-04-16 15:00:33 +00:00
/// Get the main function name.
virtual std::string getName() const = 0;
/// Create storage according to the query.
StoragePtr execute(const ASTPtr & ast_function, const Context & context) const;
virtual ~ITableFunction() {}
private:
virtual StoragePtr executeImpl(const ASTPtr & ast_function, const Context & context) const = 0;
};
using TableFunctionPtr = std::shared_ptr<ITableFunction>;
}