mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 04:22:03 +00:00
36 lines
811 B
C++
36 lines
811 B
C++
#include <Functions/FunctionFactory.h>
|
|
#include <Functions/formatReadable.h>
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
namespace
|
|
{
|
|
struct Impl
|
|
{
|
|
static constexpr auto name = "formatReadableDecimalSize";
|
|
|
|
static void format(double value, DB::WriteBuffer & out)
|
|
{
|
|
formatReadableSizeWithDecimalSuffix(value, out);
|
|
}
|
|
};
|
|
}
|
|
|
|
REGISTER_FUNCTION(FormatReadableDecimalSize)
|
|
{
|
|
factory.registerFunction<FunctionFormatReadable<Impl>>(
|
|
FunctionDocumentation{
|
|
.description=R"(
|
|
Accepts the size (number of bytes). Returns a rounded size with a suffix (KB, MB, etc.) as a string.
|
|
)",
|
|
.examples{
|
|
{"formatReadableDecimalSize", "SELECT formatReadableDecimalSize(1000)", ""}},
|
|
.categories{"OtherFunctions"}
|
|
},
|
|
FunctionFactory::CaseSensitive);
|
|
}
|
|
|
|
}
|