File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -644,6 +644,8 @@ impl ExDecimal {
644644 }
645645
646646 pub fn scale ( self ) -> usize {
647+ // A positive `exp` represents an integer. Polars requires `scale == 0`
648+ // for integers. The case where `exp > 0` is handled by `.signed_coef`.
647649 if self . exp > 0 {
648650 0
649651 } else {
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments