2019-12-09 13:12:54 +00:00
|
|
|
#include <Functions/IFunctionImpl.h>
|
2018-09-08 22:04:39 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <DataTypes/DataTypesNumber.h>
|
|
|
|
#include <Columns/ColumnsNumber.h>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
2020-09-07 18:00:37 +00:00
|
|
|
namespace
|
|
|
|
{
|
2018-09-08 22:04:39 +00:00
|
|
|
|
|
|
|
/** 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>();
|
|
|
|
}
|
|
|
|
|
2020-10-14 13:09:11 +00:00
|
|
|
void executeImpl(ColumnsWithTypeAndName & block, const ColumnNumbers &, size_t result, size_t input_rows_count) const override
|
2018-09-08 22:04:39 +00:00
|
|
|
{
|
2020-10-10 18:24:57 +00:00
|
|
|
block[result].column = ColumnUInt64::create(input_rows_count, input_rows_count);
|
2018-09-08 22:04:39 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-09-07 18:00:37 +00:00
|
|
|
}
|
2018-09-08 22:04:39 +00:00
|
|
|
|
|
|
|
void registerFunctionBlockSize(FunctionFactory & factory)
|
|
|
|
{
|
|
|
|
factory.registerFunction<FunctionBlockSize>();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|