GlareDB / glaredb

GlareDB: An analytics DBMS for distributed data
https://glaredb.com
GNU Affero General Public License v3.0
650 stars 38 forks source link

Implement `DecimalType256` to support 256 bit precision decimals #946

Open vrongmeal opened 1 year ago

vrongmeal commented 1 year ago

Summary

We want to use a 256 bit integer to store the decimal. Need to use https://docs.rs/ethnum/latest/ethnum/struct.I256.html

Specifications

Implement the required num_traits for i256 and the rest should be as easy as creating:

impl DecimalType for DecimalType256 {
    type MantissaType = i256;
    const MAX_SCALE: u8 = 76;
}

/// Compatible with arrow's `Decimal256`.
pub type Decimal256 = Decimal<DecimalType256>;

Rationale

This way we'll be able to support 256 bit numerics (not highly urgent but good to have).

Impact

Tasks

scsmithr commented 1 year ago

Do we have this?