2014-01-28 16:45:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
#include <string>
|
|
|
|
#include <memory>
|
|
|
|
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
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.
|
2014-01-28 16:45:10 +00:00
|
|
|
*
|
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.
|
2014-01-28 16:45:10 +00:00
|
|
|
*
|
2017-04-16 15:00:33 +00:00
|
|
|
* Example:
|
2014-01-28 16:45:10 +00:00
|
|
|
* 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.
|
2014-01-28 16:45:10 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
class ITableFunction
|
|
|
|
{
|
|
|
|
public:
|
2017-04-16 15:00:33 +00:00
|
|
|
/// Get the main function name.
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual std::string getName() const = 0;
|
2014-01-28 16:45:10 +00:00
|
|
|
|
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;
|
2014-02-23 00:37:25 +00:00
|
|
|
|
2017-04-01 07:20:54 +00:00
|
|
|
virtual ~ITableFunction() {};
|
2014-01-28 16:45:10 +00:00
|
|
|
};
|
|
|
|
|
2016-05-28 10:15:36 +00:00
|
|
|
using TableFunctionPtr = std::shared_ptr<ITableFunction>;
|
2014-01-28 16:45:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|