Skip to content

Support for negative scale decimals in ScalarValue #19354

@Jefffrey

Description

@Jefffrey

Is your feature request related to a problem or challenge?

In scalarvalue it seems we disallow negative scale for multiple functions, e.g.

DataType::Decimal32(precision, scale) => {
Self::validate_decimal_or_internal_err::<Decimal32Type>(
*precision, *scale,
)?;
assert_or_internal_err!(*scale >= 0, "Negative scale is not supported");
match 10_i32.checked_pow(*scale as u32) {
Some(value) => {
ScalarValue::Decimal32(Some(value), *precision, *scale)
}
None => return _internal_err!("Unsupported scale {scale}"),
}
}
DataType::Decimal64(precision, scale) => {
Self::validate_decimal_or_internal_err::<Decimal64Type>(
*precision, *scale,
)?;
assert_or_internal_err!(*scale >= 0, "Negative scale is not supported");
match i64::from(10).checked_pow(*scale as u32) {

Describe the solution you'd like

Remove these limitations and support decimals with negative scale in ScalarValue

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions