2022-10-28 15:19:54 +00:00
|
|
|
#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)
|
|
|
|
{
|
2022-11-02 07:43:47 +00:00
|
|
|
factory.registerFunction<FunctionFormatReadable<Impl>>(
|
2023-04-28 10:10:42 +00:00
|
|
|
FunctionDocumentation{
|
|
|
|
.description=R"(
|
2022-11-02 07:43:47 +00:00
|
|
|
Accepts the size (number of bytes). Returns a rounded size with a suffix (KB, MB, etc.) as a string.
|
|
|
|
)",
|
2023-04-28 10:10:42 +00:00
|
|
|
.examples{
|
|
|
|
{"formatReadableDecimalSize", "SELECT formatReadableDecimalSize(1000)", ""}},
|
|
|
|
.categories{"OtherFunctions"}
|
2022-11-02 07:43:47 +00:00
|
|
|
},
|
|
|
|
FunctionFactory::CaseSensitive);
|
2022-10-28 15:19:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|