From 9d0f69ac507b82500a71453035d7fd4f78a897bd Mon Sep 17 00:00:00 2001 From: Jack Wright <56345+ayax79@users.noreply.github.com> Date: Thu, 14 Nov 2024 20:10:38 -0800 Subject: [PATCH] Add support for converting polars decimal values to nushell values (#14343) Adds support for converting from polars decimal type to nushell values. This fix works by first converting a polars decimal series to an f64 series, then converting to Value::Float Co-authored-by: Jack Wright --- .../src/dataframe/values/nu_dataframe/conversion.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs b/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs index a920aac0a3..c2d64741f4 100644 --- a/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs +++ b/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/conversion.rs @@ -1201,6 +1201,18 @@ fn series_to_values( Ok(values) } + DataType::Decimal(_precision, _scale) => { + let casted = series + .cast(&DataType::Float64) + .map_err(|e| ShellError::GenericError { + error: "Errors casting decimal column to float".into(), + msg: "".into(), + span: None, + help: Some(e.to_string()), + inner: vec![], + })?; + series_to_values(&casted, maybe_from_row, maybe_size, span) + } e => Err(ShellError::GenericError { error: "Error creating Dataframe".into(), msg: "".to_string(),