MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / registerDataTypeDecimal

Function registerDataTypeDecimal

src/DataTypes/DataTypesDecimal.cpp:629–778  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

627template class DataTypeDecimal<Decimal256>;
628
629void registerDataTypeDecimal(DataTypeFactory & factory)
630{
631 factory.registerDataType("Decimal32", createExact<Decimal32>, DataTypeFactory::Case::Insensitive,
632 Documentation{
633 .description = "A fixed-point decimal with a fixed bit width; equivalent to `Decimal(P, S)` with a fixed precision range. See the `Decimal` entry for full documentation.",
634 .syntax = "Decimal32(S)",
635 .related = {"Decimal"},
636 });
637 factory.registerDataType("Decimal64", createExact<Decimal64>, DataTypeFactory::Case::Insensitive,
638 Documentation{
639 .description = "A fixed-point decimal with a fixed bit width; equivalent to `Decimal(P, S)` with a fixed precision range. See the `Decimal` entry for full documentation.",
640 .syntax = "Decimal64(S)",
641 .related = {"Decimal"},
642 });
643 factory.registerDataType("Decimal128", createExact<Decimal128>, DataTypeFactory::Case::Insensitive,
644 Documentation{
645 .description = "A fixed-point decimal with a fixed bit width; equivalent to `Decimal(P, S)` with a fixed precision range. See the `Decimal` entry for full documentation.",
646 .syntax = "Decimal128(S)",
647 .related = {"Decimal"},
648 });
649 factory.registerDataType("Decimal256", createExact<Decimal256>, DataTypeFactory::Case::Insensitive,
650 Documentation{
651 .description = "A fixed-point decimal with a fixed bit width; equivalent to `Decimal(P, S)` with a fixed precision range. See the `Decimal` entry for full documentation.",
652 .syntax = "Decimal256(S)",
653 .related = {"Decimal"},
654 });
655
656 factory.registerDataType("Decimal", create, DataTypeFactory::Case::Insensitive,
657 Documentation{
658 .description = R"DOCS_MD(
659Signed fixed-point numbers that keep precision during add, subtract and multiply operations. For division least significant digits are discarded (not rounded).
660
661## Parameters {#parameters}
662
663- P - precision. Valid range: \[ 1 : 76 \]. Determines how many decimal digits number can have (including fraction). By default, the precision is 10.
664- S - scale. Valid range: \[ 0 : P \]. Determines how many decimal digits fraction can have.
665
666Decimal(P) is equivalent to Decimal(P, 0). Similarly, the syntax Decimal is equivalent to Decimal(10, 0).
667
668Depending on P parameter value Decimal(P, S) is a synonym for:
669- P from \[ 1 : 9 \] - for Decimal32(S)
670- P from \[ 10 : 18 \] - for Decimal64(S)
671- P from \[ 19 : 38 \] - for Decimal128(S)
672- P from \[ 39 : 76 \] - for Decimal256(S)
673
674## Decimal Value Ranges {#decimal-value-ranges}
675
676- Decimal(P, S) - (-1 \* 10^(P - S), 1 \* 10^(P - S))
677- Decimal32(S) - (-1 \* 10^(9 - S), 1 \* 10^(9 - S))
678- Decimal64(S) - (-1 \* 10^(18 - S), 1 \* 10^(18 - S))
679- Decimal128(S) - (-1 \* 10^(38 - S), 1 \* 10^(38 - S))
680- Decimal256(S) - (-1 \* 10^(76 - S), 1 \* 10^(76 - S))
681
682For example, Decimal32(4) can contain numbers from -99999.9999 to 99999.9999 with 0.0001 step.
683
684## Internal Representation {#internal-representation}
685
686Internally data is represented as normal signed integers with respective bit width. Real value ranges that can be stored in memory are a bit larger than specified above, which are checked only on conversion from a string.

Callers 1

DataTypeFactoryMethod · 0.85

Calls 2

registerDataTypeMethod · 0.80
registerAliasMethod · 0.80

Tested by

no test coverage detected