ArrowDecimalType constructor
- int precision,
- int scale, {
- int bitWidth = 128,
Creates a decimal of bitWidth 32, 64, 128 (default), or 256 bits.
Maximum precision is 9, 18, 38, or 76 respectively. scale may be
any signed 32-bit integer, as Arrow permits: negative scales and scales
greater than precision are valid (value = unscaled * 10^-scale).
This is a deliberate expansion over earlier releases that required
0 <= scale <= precision. Consumers such as the Polars native boundary
that do not support these scales or non-128-bit widths must reject them.
Implementation
ArrowDecimalType(this.precision, this.scale, {this.bitWidth = 128}) {
final maxPrecision = switch (bitWidth) {
32 => 9,
64 => 18,
128 => 38,
256 => 76,
_ => throw ArgumentError.value(
bitWidth,
'bitWidth',
'must be 32, 64, 128, or 256',
),
};
if (precision < 1 || precision > maxPrecision) {
throw RangeError.range(precision, 1, maxPrecision, 'precision');
}
if (scale < -0x80000000 || scale > 0x7fffffff) {
throw RangeError.range(scale, -0x80000000, 0x7fffffff, 'scale');
}
}