Skip to content

Commit ead3a33

Browse files
committed
restore original code with a fix for type
1 parent d1242d6 commit ead3a33

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

native/explorer/src/datatypes.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,8 +644,6 @@ impl ExDecimal {
644644
}
645645

646646
pub fn scale(self) -> usize {
647-
if self.exp > 0 {
648-
649647
// A positive `exp` represents an integer. Polars requires `scale == 0`
650648
// for integers. The case where `exp > 0` is handled by `.signed_coef`.
651649
if self.exp > 0 {

native/explorer/src/series/from_list.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,17 @@ pub fn s_from_list_decimal(
240240
})
241241
}
242242

243-
TermType::Map => {
244-
match item.decode::<ExDecimal>() {
245-
Ok(ex_decimal) => ex_decimal
246-
.signed_coef()
247-
.map(|coef| AnyValue::Decimal(coef, ex_decimal.scale())),
248-
Err(error) => Err(ExplorerError::Other(format!(
243+
TermType::Map => item
244+
.decode::<ExDecimal>()
245+
.map_err(|error| {
246+
ExplorerError::Other(format!(
249247
"cannot decode a valid decimal from term; check that `coef` fits into an `i128`. error: {error:?}"
250-
))),
251-
}
252-
}
248+
))
249+
})
250+
.and_then(|ex_decimal| {
251+
ex_decimal.signed_coef().map(|coef| AnyValue::Decimal(coef, ex_decimal.scale()))
252+
}),
253+
253254
TermType::Atom => Ok(AnyValue::Null),
254255

255256
TermType::Float => item

0 commit comments

Comments
 (0)