ClickHouse/src/Functions/blockSize.cpp

60 lines
1.3 KiB
C++
Raw Normal View History

#include <Functions/IFunctionImpl.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypesNumber.h>
#include <Columns/ColumnsNumber.h>
namespace DB
{
2020-09-07 18:00:37 +00:00
namespace
{
/** blockSize() - get the block size in number of rows.
*/
class FunctionBlockSize : public IFunction
{
public:
static constexpr auto name = "blockSize";
static FunctionPtr create(const Context &)
{
return std::make_shared<FunctionBlockSize>();
}
/// Get the function name.
String getName() const override
{
return name;
}
bool isDeterministic() const override { return false; }
bool isDeterministicInScopeOfQuery() const override
{
return false;
}
size_t getNumberOfArguments() const override
{
return 0;
}
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
{
return std::make_shared<DataTypeUInt64>();
}
void executeImpl(ColumnsWithTypeAndName & block, const ColumnNumbers &, size_t result, size_t input_rows_count) const override
{
2020-10-10 18:24:57 +00:00
block[result].column = ColumnUInt64::create(input_rows_count, input_rows_count);
}
};
2020-09-07 18:00:37 +00:00
}
void registerFunctionBlockSize(FunctionFactory & factory)
{
factory.registerFunction<FunctionBlockSize>();
}
}