Upgrading nu_plugin_polars to polars 0.39.1 (#12551)

# Description
Upgrading nu_plugin_polars to polars 0.39.1

Co-authored-by: Jack Wright <jack.wright@disqo.com>
This commit is contained in:
Jack Wright
2024-04-17 04:35:09 -07:00
committed by GitHub
parent b296d6ee3c
commit 410f3c5c8a
6 changed files with 541 additions and 106 deletions

View File

@ -9,6 +9,7 @@ use nu_protocol::{
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, SyntaxShape, Type,
Value,
};
use polars::chunked_array::ops::SortMultipleOptions;
#[derive(Clone)]
pub struct LazySortBy;
@ -137,12 +138,18 @@ impl PluginCommand for LazySortBy {
None => expressions.iter().map(|_| false).collect::<Vec<bool>>(),
};
let sort_options = SortMultipleOptions {
descending: reverse,
nulls_last,
multithreaded: true,
maintain_order,
};
let pipeline_value = input.into_value(call.head);
let lazy = NuLazyFrame::try_from_value_coerce(plugin, &pipeline_value)?;
let lazy = NuLazyFrame::new(
lazy.from_eager,
lazy.to_polars()
.sort_by_exprs(&expressions, reverse, nulls_last, maintain_order),
lazy.to_polars().sort_by_exprs(&expressions, sort_options),
);
lazy.to_pipeline_data(plugin, engine, call.head)
.map_err(LabeledError::from)