aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/formatReadableDecimalSize.cpp
blob: b6fd0de8f7b4a0d92d19145dd79390fdb883898f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#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);
}

}