Skip to content

Optimize the validation of Decimal256 #2320

@liukun4515

Description

@liukun4515

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

When arrow construct a decimal array, we need to verify the data of decimal with the precision.

From current implemention

pub(crate) fn validate_decimal_precision(value: i128, precision: usize) -> Result<i128> {
and
pub(crate) fn validate_decimal256_precision(

We compare the decimal using i128 or string, it may be inefficient.

optimize the validation using the byte array instead of i128 or string.

Describe the solution you'd like

For exmaple, precision 3, The max value is i128.to_le_byte(999), and the min value if i128.to_le_byte(-999).
Comparing the decimal128(value,precision,scale) just need to compare the value ([u8;16]) with the min and max.

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

Labels

arrowChanges to the arrow crateenhancementAny new improvement worthy of a entry in the changelog

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions