ClickHouse/dbms/src/TableFunctions/ITableFunction.h

44 lines
981 B
C++
Raw Normal View History

#pragma once
#include <string>
#include <memory>
namespace DB
{
class Context;
class IAST;
using ASTPtr = std::shared_ptr<IAST>;
class IStorage;
using StoragePtr = std::shared_ptr<IStorage>;
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;
2017-04-16 15:00:33 +00:00
/// Create storage according to the query
2017-05-23 18:46:52 +00:00
virtual StoragePtr execute(const ASTPtr & ast_function, const Context & context) const = 0;
virtual ~ITableFunction() {};
};
using TableFunctionPtr = std::shared_ptr<ITableFunction>;
}