2017-06-10 09:04:31 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <TableFunctions/ITableFunction.h>
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/types.h>
|
2017-06-10 09:04:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-08-19 12:27:51 +00:00
|
|
|
/* numbers(limit), numbers_mt(limit)
|
2017-06-10 09:04:31 +00:00
|
|
|
* - the same as SELECT number FROM system.numbers LIMIT limit.
|
|
|
|
* Used for testing purposes, as a simple example of table function.
|
|
|
|
*/
|
2019-08-19 12:27:51 +00:00
|
|
|
template <bool multithreaded>
|
2017-06-10 09:04:31 +00:00
|
|
|
class TableFunctionNumbers : public ITableFunction
|
|
|
|
{
|
|
|
|
public:
|
2019-08-19 12:27:51 +00:00
|
|
|
static constexpr auto name = multithreaded ? "numbers_mt" : "numbers";
|
2017-06-10 09:04:31 +00:00
|
|
|
std::string getName() const override { return name; }
|
2020-10-14 12:19:29 +00:00
|
|
|
bool hasStaticStructure() const override { return true; }
|
2018-03-02 05:03:28 +00:00
|
|
|
private:
|
2021-04-10 23:33:54 +00:00
|
|
|
StoragePtr executeImpl(const ASTPtr & ast_function, ContextPtr context, const std::string & table_name, ColumnsDescription cached_columns) const override;
|
2020-04-06 05:19:40 +00:00
|
|
|
const char * getStorageTypeName() const override { return "SystemNumbers"; }
|
2018-06-20 08:09:09 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
UInt64 evaluateArgument(ContextPtr context, ASTPtr & argument) const;
|
2020-10-14 12:19:29 +00:00
|
|
|
|
2021-04-10 23:33:54 +00:00
|
|
|
ColumnsDescription getActualTableStructure(ContextPtr context) const override;
|
2017-06-10 09:04:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|