2020-03-10 14:54:22 +00:00
|
|
|
#pragma once
|
2020-03-10 13:14:49 +00:00
|
|
|
|
2020-03-10 14:54:22 +00:00
|
|
|
#include <TableFunctions/ITableFunction.h>
|
2020-09-15 09:55:57 +00:00
|
|
|
#include <common/types.h>
|
2020-03-10 13:14:49 +00:00
|
|
|
|
|
|
|
|
2020-03-10 14:54:22 +00:00
|
|
|
namespace DB
|
2020-03-10 13:14:49 +00:00
|
|
|
{
|
|
|
|
|
2020-03-10 14:54:22 +00:00
|
|
|
/* zeros(limit), zeros_mt(limit)
|
2020-03-10 18:17:16 +00:00
|
|
|
* - the same as SELECT zero FROM system.zeros LIMIT limit.
|
2020-03-10 14:54:22 +00:00
|
|
|
* Used for testing purposes, as a simple example of table function.
|
|
|
|
*/
|
|
|
|
template <bool multithreaded>
|
|
|
|
class TableFunctionZeros : public ITableFunction
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static constexpr auto name = multithreaded ? "zeros_mt" : "zeros";
|
|
|
|
std::string getName() const override { return name; }
|
2020-10-14 12:19:29 +00:00
|
|
|
bool hasStaticStructure() const override { return true; }
|
2020-03-10 14:54:22 +00:00
|
|
|
private:
|
2020-10-14 12:19:29 +00:00
|
|
|
StoragePtr executeImpl(const ASTPtr & ast_function, const Context & 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 "SystemZeros"; }
|
2020-03-10 14:54:22 +00:00
|
|
|
|
|
|
|
UInt64 evaluateArgument(const Context & context, ASTPtr & argument) const;
|
2020-10-14 12:19:29 +00:00
|
|
|
|
|
|
|
ColumnsDescription getActualTableStructure(const Context & context) const override;
|
2020-03-10 13:14:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-03-10 14:54:22 +00:00
|
|
|
}
|