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 <jack.wright@nike.com>
This commit is contained in:
Jack Wright 2024-11-14 20:10:38 -08:00 committed by GitHub
parent 215ca6c5ca
commit 9d0f69ac50
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1201,6 +1201,18 @@ fn series_to_values(
Ok(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 { e => Err(ShellError::GenericError {
error: "Error creating Dataframe".into(), error: "Error creating Dataframe".into(),
msg: "".to_string(), msg: "".to_string(),