mirror of
https://github.com/nushell/nushell.git
synced 2025-04-23 12:48:22 +02:00
Cleaning up to_pipe_line_data and cache_and_to_value, making them part of CustomValueSupport (#12528)
# Description This is just some cleanup. I moved to_pipeline_data and to_cache_value to the CustomValueSupport trait, where I should've put them to begin with. Co-authored-by: Jack Wright <jack.wright@disqo.com>
This commit is contained in:
parent
c9e9b138eb
commit
1661bb68f9
@ -5,7 +5,7 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
values::{to_pipeline_data, Axis, Column, CustomValueSupport, NuDataFrame},
|
values::{Axis, Column, CustomValueSupport, NuDataFrame},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ fn command(
|
|||||||
let df = NuDataFrame::try_from_pipeline(plugin, input, call.head)?;
|
let df = NuDataFrame::try_from_pipeline(plugin, input, call.head)?;
|
||||||
let df = df.append_df(&df_other, axis, call.head)?;
|
let df = df.append_df(&df_other, axis, call.head)?;
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{str_to_dtype, to_pipeline_data, NuExpression, NuLazyFrame},
|
dataframe::values::{str_to_dtype, NuExpression, NuLazyFrame},
|
||||||
values::{cant_convert_err, PolarsPluginObject, PolarsPluginType},
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ impl PluginCommand for CastDF {
|
|||||||
let dtype: String = call.req(0)?;
|
let dtype: String = call.req(0)?;
|
||||||
let dtype = str_to_dtype(&dtype, call.head)?;
|
let dtype = str_to_dtype(&dtype, call.head)?;
|
||||||
let expr: NuExpression = expr.to_polars().cast(dtype).into();
|
let expr: NuExpression = expr.to_polars().cast(dtype).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
_ => Err(cant_convert_err(
|
_ => Err(cant_convert_err(
|
||||||
&value,
|
&value,
|
||||||
@ -145,7 +145,7 @@ fn command_lazy(
|
|||||||
let column = col(&column_nm).cast(dtype);
|
let column = col(&column_nm).cast(dtype);
|
||||||
let lazy = lazy.to_polars().with_columns(&[column]);
|
let lazy = lazy.to_polars().with_columns(&[column]);
|
||||||
let lazy = NuLazyFrame::new(false, lazy);
|
let lazy = NuLazyFrame::new(false, lazy);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_eager(
|
fn command_eager(
|
||||||
@ -186,7 +186,7 @@ fn command_eager(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df = NuDataFrame::new(false, df);
|
let df = NuDataFrame::new(false, df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
use crate::values::to_pipeline_data;
|
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, SyntaxShape, Type,
|
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, SyntaxShape, Type,
|
||||||
@ -112,7 +111,7 @@ fn command(
|
|||||||
|
|
||||||
let final_df = NuDataFrame::new(df.from_lazy, polars_df);
|
let final_df = NuDataFrame::new(df.from_lazy, polars_df);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, final_df)
|
final_df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -5,7 +5,7 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
use polars::prelude::UniqueKeepStrategy;
|
use polars::prelude::UniqueKeepStrategy;
|
||||||
|
|
||||||
use crate::values::{to_pipeline_data, CustomValueSupport};
|
use crate::values::CustomValueSupport;
|
||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
|
|
||||||
use super::super::values::utils::convert_columns_string;
|
use super::super::values::utils::convert_columns_string;
|
||||||
@ -117,7 +117,7 @@ fn command(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -4,7 +4,7 @@ use nu_protocol::{
|
|||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::values::{to_pipeline_data, CustomValueSupport};
|
use crate::values::CustomValueSupport;
|
||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
|
|
||||||
use super::super::values::utils::convert_columns_string;
|
use super::super::values::utils::convert_columns_string;
|
||||||
@ -134,7 +134,7 @@ fn command(
|
|||||||
inner: vec![],
|
inner: vec![],
|
||||||
})?;
|
})?;
|
||||||
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
|
|
||||||
use super::super::values::{to_pipeline_data, Column, CustomValueSupport, NuDataFrame};
|
use super::super::values::{Column, CustomValueSupport, NuDataFrame};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Type, Value,
|
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||||
@ -96,7 +96,7 @@ fn command(
|
|||||||
let dtypes_col = Column::new("dtype".to_string(), dtypes);
|
let dtypes_col = Column::new("dtype".to_string(), dtypes);
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_columns(vec![names_col, dtypes_col], None)?;
|
let df = NuDataFrame::try_from_columns(vec![names_col, dtypes_col], None)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use super::super::values::NuDataFrame;
|
use super::super::values::NuDataFrame;
|
||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Type,
|
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Type,
|
||||||
@ -103,7 +100,7 @@ fn command(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df: NuDataFrame = polars_df.into();
|
let df: NuDataFrame = polars_df.into();
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -7,10 +7,7 @@ use polars::prelude::LazyFrame;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{NuExpression, NuLazyFrame},
|
dataframe::values::{NuExpression, NuLazyFrame},
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -114,7 +111,7 @@ fn command_eager(
|
|||||||
let lazy = df.lazy();
|
let lazy = df.lazy();
|
||||||
let lazy = lazy.apply_with_expr(expression, LazyFrame::filter);
|
let lazy = lazy.apply_with_expr(expression, LazyFrame::filter);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
} else {
|
} else {
|
||||||
let mask = NuDataFrame::try_from_value_coerce(plugin, &mask_value, mask_span)?
|
let mask = NuDataFrame::try_from_value_coerce(plugin, &mask_value, mask_span)?
|
||||||
.as_series(mask_span)?;
|
.as_series(mask_span)?;
|
||||||
@ -137,7 +134,7 @@ fn command_eager(
|
|||||||
inner: vec![],
|
inner: vec![],
|
||||||
})?;
|
})?;
|
||||||
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,7 +147,7 @@ fn command_lazy(
|
|||||||
let expr: Value = call.req(0)?;
|
let expr: Value = call.req(0)?;
|
||||||
let expr = NuExpression::try_from_value(plugin, &expr)?;
|
let expr = NuExpression::try_from_value(plugin, &expr)?;
|
||||||
let lazy = lazy.apply_with_expr(expr, LazyFrame::filter);
|
let lazy = lazy.apply_with_expr(expr, LazyFrame::filter);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
values::{to_pipeline_data, Column, CustomValueSupport},
|
values::{Column, CustomValueSupport},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -105,7 +105,8 @@ impl PluginCommand for FirstDF {
|
|||||||
let expr = NuExpression::try_from_value(plugin, &value)?;
|
let expr = NuExpression::try_from_value(plugin, &value)?;
|
||||||
let expr: NuExpression = expr.to_polars().first().into();
|
let expr: NuExpression = expr.to_polars().first().into();
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +123,7 @@ fn command(
|
|||||||
let res = df.as_ref().head(Some(rows));
|
let res = df.as_ref().head(Some(rows));
|
||||||
let res = NuDataFrame::new(false, res);
|
let res = NuDataFrame::new(false, res);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, res)
|
res.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -5,9 +5,7 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::utils::convert_columns_string,
|
dataframe::values::utils::convert_columns_string, values::CustomValueSupport, PolarsPlugin,
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
@ -87,7 +85,7 @@ fn command(
|
|||||||
inner: vec![],
|
inner: vec![],
|
||||||
})?;
|
})?;
|
||||||
let df = NuDataFrame::new(false, df);
|
let df = NuDataFrame::new(false, df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
values::{to_pipeline_data, Column, CustomValueSupport},
|
values::{Column, CustomValueSupport},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,7 +80,8 @@ impl PluginCommand for LastDF {
|
|||||||
let expr = NuExpression::try_from_value(plugin, &value)?;
|
let expr = NuExpression::try_from_value(plugin, &value)?;
|
||||||
let expr: NuExpression = expr.to_polars().last().into();
|
let expr: NuExpression = expr.to_polars().last().into();
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +97,7 @@ fn command(
|
|||||||
|
|
||||||
let res = df.as_ref().tail(Some(rows));
|
let res = df.as_ref().tail(Some(rows));
|
||||||
let res = NuDataFrame::new(false, res);
|
let res = NuDataFrame::new(false, res);
|
||||||
to_pipeline_data(plugin, engine, call.head, res)
|
res.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -5,9 +5,7 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::utils::convert_columns_string,
|
dataframe::values::utils::convert_columns_string, values::CustomValueSupport, PolarsPlugin,
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
@ -182,7 +180,7 @@ fn command(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let res = NuDataFrame::new(false, res);
|
let res = NuDataFrame::new(false, res);
|
||||||
to_pipeline_data(plugin, engine, call.head, res)
|
res.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_column_datatypes<T: AsRef<str>>(
|
fn check_column_datatypes<T: AsRef<str>>(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::NuSchema,
|
dataframe::values::NuSchema,
|
||||||
values::{cache_and_to_value, NuLazyFrame},
|
values::{CustomValueSupport, NuLazyFrame},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_path::expand_path_with;
|
use nu_path::expand_path_with;
|
||||||
@ -187,7 +187,7 @@ fn from_parquet(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
} else {
|
} else {
|
||||||
let columns: Option<Vec<String>> = call.get_flag("columns")?;
|
let columns: Option<Vec<String>> = call.get_flag("columns")?;
|
||||||
|
|
||||||
@ -216,7 +216,7 @@ fn from_parquet(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +254,7 @@ fn from_avro(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_ipc(
|
fn from_ipc(
|
||||||
@ -284,7 +284,7 @@ fn from_ipc(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
} else {
|
} else {
|
||||||
let columns: Option<Vec<String>> = call.get_flag("columns")?;
|
let columns: Option<Vec<String>> = call.get_flag("columns")?;
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ fn from_ipc(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ fn from_json(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_jsonl(
|
fn from_jsonl(
|
||||||
@ -399,7 +399,7 @@ fn from_jsonl(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn from_csv(
|
fn from_csv(
|
||||||
@ -472,7 +472,7 @@ fn from_csv(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
} else {
|
} else {
|
||||||
let csv_reader = CsvReader::from_path(file_path)
|
let csv_reader = CsvReader::from_path(file_path)
|
||||||
.map_err(|e| ShellError::GenericError {
|
.map_err(|e| ShellError::GenericError {
|
||||||
@ -538,6 +538,6 @@ fn from_csv(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
cache_and_to_value(plugin, engine, call.head, df)
|
df.cache_and_to_value(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::super::values::NuDataFrame;
|
use super::super::values::NuDataFrame;
|
||||||
use crate::dataframe::values::Column;
|
use crate::dataframe::values::Column;
|
||||||
use crate::dataframe::{eager::SQLContext, values::NuLazyFrame};
|
use crate::dataframe::{eager::SQLContext, values::NuLazyFrame};
|
||||||
use crate::values::{to_pipeline_data, CustomValueSupport};
|
use crate::values::CustomValueSupport;
|
||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
@ -92,7 +92,7 @@ fn command(
|
|||||||
inner: vec![],
|
inner: vec![],
|
||||||
})?;
|
})?;
|
||||||
let lazy = NuLazyFrame::new(!df.from_lazy, df_sql);
|
let lazy = NuLazyFrame::new(!df.from_lazy, df_sql);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -6,7 +6,7 @@ use nu_protocol::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dataframe::{utils::extract_strings, values::NuLazyFrame},
|
dataframe::{utils::extract_strings, values::NuLazyFrame},
|
||||||
values::{to_pipeline_data, CustomValueSupport, PolarsPluginObject},
|
values::{CustomValueSupport, PolarsPluginObject},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ fn command_eager(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let df = NuDataFrame::new(false, polars_df);
|
let df = NuDataFrame::new(false, polars_df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_lazy(
|
fn command_lazy(
|
||||||
@ -187,7 +187,7 @@ fn command_lazy(
|
|||||||
let lazy = lazy.to_polars();
|
let lazy = lazy.to_polars();
|
||||||
let lazy: NuLazyFrame = lazy.rename(&columns, &new_names).into();
|
let lazy: NuLazyFrame = lazy.rename(&columns, &new_names).into();
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -6,10 +6,7 @@ use nu_protocol::{
|
|||||||
use polars::prelude::NamedFrom;
|
use polars::prelude::NamedFrom;
|
||||||
use polars::series::Series;
|
use polars::series::Series;
|
||||||
|
|
||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::NuDataFrame;
|
use super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -134,5 +131,5 @@ fn command(
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
let df = NuDataFrame::new(false, df?);
|
let df = NuDataFrame::new(false, df?);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,7 @@ use nu_protocol::{
|
|||||||
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Type, Value,
|
Category, Example, LabeledError, PipelineData, ShellError, Signature, Span, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{dataframe::values::Column, values::CustomValueSupport, PolarsPlugin};
|
||||||
dataframe::values::Column,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::NuDataFrame;
|
use super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -79,7 +75,7 @@ fn command(
|
|||||||
let cols_col = Column::new("columns".to_string(), vec![cols]);
|
let cols_col = Column::new("columns".to_string(), vec![cols]);
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_columns(vec![rows_col, cols_col], None)?;
|
let df = NuDataFrame::try_from_columns(vec![rows_col, cols_col], None)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -4,11 +4,7 @@ use nu_protocol::{
|
|||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{dataframe::values::Column, values::CustomValueSupport, PolarsPlugin};
|
||||||
dataframe::values::Column,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::NuDataFrame;
|
use super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -80,7 +76,7 @@ fn command(
|
|||||||
let res = df.as_ref().slice(offset, size);
|
let res = df.as_ref().slice(offset, size);
|
||||||
let res = NuDataFrame::new(false, res);
|
let res = NuDataFrame::new(false, res);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, res)
|
res.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -277,7 +274,7 @@ fn command(
|
|||||||
|
|
||||||
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -5,11 +5,7 @@ use nu_protocol::{
|
|||||||
};
|
};
|
||||||
use polars::prelude::DataType;
|
use polars::prelude::DataType;
|
||||||
|
|
||||||
use crate::{
|
use crate::{dataframe::values::Column, values::CustomValueSupport, PolarsPlugin};
|
||||||
dataframe::values::Column,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::NuDataFrame;
|
use super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -147,7 +143,7 @@ fn command(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::NuSchema,
|
dataframe::values::NuSchema,
|
||||||
values::{to_pipeline_data, Column, CustomValueSupport},
|
values::{Column, CustomValueSupport},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -183,7 +183,8 @@ impl PluginCommand for ToDataFrame {
|
|||||||
.transpose()?;
|
.transpose()?;
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_iter(plugin, input.into_iter(), maybe_schema.clone())?;
|
let df = NuDataFrame::try_from_iter(plugin, input.into_iter(), maybe_schema.clone())?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df).map_err(LabeledError::from)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{NuExpression, NuLazyFrame},
|
dataframe::values::{NuExpression, NuLazyFrame},
|
||||||
values::{to_pipeline_data, CustomValueSupport, PolarsPluginObject},
|
values::{CustomValueSupport, PolarsPluginObject},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -143,7 +143,7 @@ fn command_eager(
|
|||||||
let expressions = NuExpression::extract_exprs(plugin, value)?;
|
let expressions = NuExpression::extract_exprs(plugin, value)?;
|
||||||
let lazy = NuLazyFrame::new(true, df.lazy().to_polars().with_columns(&expressions));
|
let lazy = NuLazyFrame::new(true, df.lazy().to_polars().with_columns(&expressions));
|
||||||
let df = lazy.collect(call.head)?;
|
let df = lazy.collect(call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
} else {
|
} else {
|
||||||
let mut other = NuDataFrame::try_from_value(plugin, &new_column)?.as_series(column_span)?;
|
let mut other = NuDataFrame::try_from_value(plugin, &new_column)?.as_series(column_span)?;
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ fn command_eager(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
let df = NuDataFrame::new(df.from_lazy, polars_df);
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +180,7 @@ fn command_lazy(
|
|||||||
let value = Value::list(vals, call.head);
|
let value = Value::list(vals, call.head);
|
||||||
let expressions = NuExpression::extract_exprs(plugin, value)?;
|
let expressions = NuExpression::extract_exprs(plugin, value)?;
|
||||||
let lazy: NuLazyFrame = lazy.to_polars().with_columns(&expressions).into();
|
let lazy: NuLazyFrame = lazy.to_polars().with_columns(&expressions).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::NuExpression;
|
use super::super::values::NuExpression;
|
||||||
|
|
||||||
@ -72,7 +69,8 @@ impl PluginCommand for ExprAlias {
|
|||||||
let expr = NuExpression::try_from_pipeline(plugin, input, call.head)?;
|
let expr = NuExpression::try_from_pipeline(plugin, input, call.head)?;
|
||||||
let expr: NuExpression = expr.to_polars().alias(alias.as_str()).into();
|
let expr: NuExpression = expr.to_polars().alias(alias.as_str()).into();
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression},
|
dataframe::values::{Column, NuDataFrame, NuExpression},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -63,7 +63,8 @@ impl PluginCommand for ExprArgWhere {
|
|||||||
let value: Value = call.req(0)?;
|
let value: Value = call.req(0)?;
|
||||||
let expr = NuExpression::try_from_value(plugin, &value)?;
|
let expr = NuExpression::try_from_value(plugin, &value)?;
|
||||||
let expr: NuExpression = arg_where(expr.to_polars()).into();
|
let expr: NuExpression = arg_where(expr.to_polars()).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{dataframe::values::NuExpression, values::to_pipeline_data, PolarsPlugin};
|
use crate::{dataframe::values::NuExpression, values::CustomValueSupport, PolarsPlugin};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
record, Category, Example, LabeledError, PipelineData, Signature, SyntaxShape, Type, Value,
|
record, Category, Example, LabeledError, PipelineData, Signature, SyntaxShape, Type, Value,
|
||||||
@ -54,7 +54,8 @@ impl PluginCommand for ExprCol {
|
|||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let name: String = call.req(0)?;
|
let name: String = call.req(0)?;
|
||||||
let expr: NuExpression = col(name.as_str()).into();
|
let expr: NuExpression = col(name.as_str()).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression},
|
dataframe::values::{Column, NuDataFrame, NuExpression},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -92,7 +92,8 @@ impl PluginCommand for ExprConcatStr {
|
|||||||
let expressions = NuExpression::extract_exprs(plugin, value)?;
|
let expressions = NuExpression::extract_exprs(plugin, value)?;
|
||||||
let expr: NuExpression = concat_str(expressions, &separator, false).into();
|
let expr: NuExpression = concat_str(expressions, &separator, false).into();
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use super::super::values::NuExpression;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame},
|
dataframe::values::{Column, NuDataFrame},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use chrono::{DateTime, FixedOffset};
|
use chrono::{DateTime, FixedOffset};
|
||||||
@ -149,7 +149,8 @@ impl PluginCommand for ExprDatePart {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}.into();
|
}.into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/// All of these expressions have an identical body and only require
|
/// All of these expressions have an identical body and only require
|
||||||
/// to have a change in the name, description and expression function
|
/// to have a change in the name, description and expression function
|
||||||
use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame};
|
use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame};
|
||||||
use crate::values::{to_pipeline_data, CustomValueSupport};
|
use crate::values::CustomValueSupport;
|
||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
@ -51,7 +51,8 @@ macro_rules! expr_command {
|
|||||||
let expr = NuExpression::try_from_pipeline(plugin, input, call.head)
|
let expr = NuExpression::try_from_pipeline(plugin, input, call.head)
|
||||||
.map_err(LabeledError::from)?;
|
.map_err(LabeledError::from)?;
|
||||||
let expr: NuExpression = expr.to_polars().$func().into();
|
let expr: NuExpression = expr.to_polars().$func().into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +96,8 @@ macro_rules! expr_command {
|
|||||||
let expr = NuExpression::try_from_pipeline(input, call.head)
|
let expr = NuExpression::try_from_pipeline(input, call.head)
|
||||||
.map_err(LabeledError::from)?;
|
.map_err(LabeledError::from)?;
|
||||||
let expr: NuExpression = expr.into_polars().$func($ddof).into();
|
let expr: NuExpression = expr.into_polars().$func($ddof).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,12 +176,14 @@ macro_rules! lazy_expr_command {
|
|||||||
})
|
})
|
||||||
.map_err(LabeledError::from)?,
|
.map_err(LabeledError::from)?,
|
||||||
);
|
);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
} else {
|
} else {
|
||||||
let expr =
|
let expr =
|
||||||
NuExpression::try_from_value(plugin, &value).map_err(LabeledError::from)?;
|
NuExpression::try_from_value(plugin, &value).map_err(LabeledError::from)?;
|
||||||
let expr: NuExpression = expr.to_polars().$func().into();
|
let expr: NuExpression = expr.to_polars().$func().into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -253,11 +257,13 @@ macro_rules! lazy_expr_command {
|
|||||||
})
|
})
|
||||||
.map_err(LabeledError::from)?,
|
.map_err(LabeledError::from)?,
|
||||||
);
|
);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
} else {
|
} else {
|
||||||
let expr = NuExpression::try_from_value(plugin, &value)?;
|
let expr = NuExpression::try_from_value(plugin, &value)?;
|
||||||
let expr: NuExpression = expr.to_polars().$func($ddof).into();
|
let expr: NuExpression = expr.to_polars().$func($ddof).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression},
|
dataframe::values::{Column, NuDataFrame, NuExpression},
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -157,7 +154,7 @@ fn command_expr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let expr: NuExpression = expr.to_polars().is_in(lit(list)).into();
|
let expr: NuExpression = expr.to_polars().is_in(lit(list)).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_df(
|
fn command_df(
|
||||||
@ -185,7 +182,7 @@ fn command_df(
|
|||||||
res.rename("is_in");
|
res.rename("is_in");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
use crate::{
|
use crate::{dataframe::values::NuExpression, values::CustomValueSupport, PolarsPlugin};
|
||||||
dataframe::values::NuExpression,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
record, Category, Example, LabeledError, PipelineData, Signature, SyntaxShape, Type, Value,
|
record, Category, Example, LabeledError, PipelineData, Signature, SyntaxShape, Type, Value,
|
||||||
@ -57,7 +53,8 @@ impl PluginCommand for ExprLit {
|
|||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let literal: Value = call.req(0)?;
|
let literal: Value = call.req(0)?;
|
||||||
let expr = NuExpression::try_from_value(plugin, &literal)?;
|
let expr = NuExpression::try_from_value(plugin, &literal)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, expr).map_err(LabeledError::from)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression, NuWhen, NuWhenType},
|
dataframe::values::{Column, NuDataFrame, NuExpression, NuWhen, NuWhenType},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -106,7 +106,9 @@ impl PluginCommand for ExprOtherwise {
|
|||||||
.otherwise(otherwise_predicate.to_polars())
|
.otherwise(otherwise_predicate.to_polars())
|
||||||
.into(),
|
.into(),
|
||||||
};
|
};
|
||||||
to_pipeline_data(plugin, engine, call.head, complete).map_err(LabeledError::from)
|
complete
|
||||||
|
.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression, NuWhen},
|
dataframe::values::{Column, NuDataFrame, NuExpression, NuWhen},
|
||||||
values::{to_pipeline_data, CustomValueSupport, NuWhenType},
|
values::{CustomValueSupport, NuWhenType},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -128,7 +128,9 @@ impl PluginCommand for ExprWhen {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, when_then).map_err(LabeledError::from)
|
when_then
|
||||||
|
.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{NuExpression, NuLazyFrame, NuLazyGroupBy},
|
dataframe::values::{NuExpression, NuLazyFrame, NuLazyGroupBy},
|
||||||
values::{to_pipeline_data, Column, CustomValueSupport, NuDataFrame},
|
values::{Column, CustomValueSupport, NuDataFrame},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -148,7 +148,8 @@ impl PluginCommand for LazyAggregate {
|
|||||||
|
|
||||||
let polars = group_by.to_polars();
|
let polars = group_by.to_polars();
|
||||||
let lazy = NuLazyFrame::new(false, polars.agg(&expressions));
|
let lazy = NuLazyFrame::new(false, polars.agg(&expressions));
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame};
|
use crate::dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame};
|
||||||
use crate::values::{to_pipeline_data, CustomValueSupport, PolarsPluginObject};
|
use crate::values::{CustomValueSupport, PolarsPluginObject};
|
||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
|
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -151,7 +151,7 @@ pub(crate) fn explode_lazy(
|
|||||||
.explode(columns.iter().map(AsRef::as_ref).collect::<Vec<&str>>());
|
.explode(columns.iter().map(AsRef::as_ref).collect::<Vec<&str>>());
|
||||||
let lazy = NuLazyFrame::from(exploded);
|
let lazy = NuLazyFrame::from(exploded);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn explode_expr(
|
pub(crate) fn explode_expr(
|
||||||
@ -161,8 +161,9 @@ pub(crate) fn explode_expr(
|
|||||||
expr: NuExpression,
|
expr: NuExpression,
|
||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let expr: NuExpression = expr.to_polars().explode().into();
|
let expr: NuExpression = expr.to_polars().explode().into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::dataframe::values::{Column, NuDataFrame};
|
use crate::dataframe::values::{Column, NuDataFrame};
|
||||||
use crate::values::{to_pipeline_data, CustomValueSupport, NuLazyFrame};
|
use crate::values::{CustomValueSupport, NuLazyFrame};
|
||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{
|
use nu_protocol::{
|
||||||
@ -84,7 +84,9 @@ impl PluginCommand for LazyFetch {
|
|||||||
|
|
||||||
// mark this as not from lazy so it doesn't get converted back to a lazy frame
|
// mark this as not from lazy so it doesn't get converted back to a lazy frame
|
||||||
eager.from_lazy = false;
|
eager.from_lazy = false;
|
||||||
to_pipeline_data(plugin, engine, call.head, eager).map_err(LabeledError::from)
|
eager
|
||||||
|
.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression},
|
dataframe::values::{Column, NuDataFrame, NuExpression},
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -161,7 +158,7 @@ fn cmd_df(
|
|||||||
})
|
})
|
||||||
.collect::<Vec<Column>>();
|
.collect::<Vec<Column>>();
|
||||||
let df = NuDataFrame::try_from_columns(dataframe, None)?;
|
let df = NuDataFrame::try_from_columns(dataframe, None)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cmd_expr(
|
fn cmd_expr(
|
||||||
@ -173,8 +170,7 @@ fn cmd_expr(
|
|||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars();
|
let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars();
|
||||||
let expr: NuExpression = expr.to_polars().fill_nan(fill).into();
|
let expr: NuExpression = expr.to_polars().fill_nan(fill).into();
|
||||||
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -100,7 +97,7 @@ fn cmd_lazy(
|
|||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let expr = NuExpression::try_from_value(plugin, &fill)?.to_polars();
|
let expr = NuExpression::try_from_value(plugin, &fill)?.to_polars();
|
||||||
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().fill_null(expr));
|
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().fill_null(expr));
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cmd_expr(
|
fn cmd_expr(
|
||||||
@ -112,7 +109,7 @@ fn cmd_expr(
|
|||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars();
|
let fill = NuExpression::try_from_value(plugin, &fill)?.to_polars();
|
||||||
let expr: NuExpression = expr.to_polars().fill_null(fill).into();
|
let expr: NuExpression = expr.to_polars().fill_null(fill).into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ fn command(
|
|||||||
lazy.from_eager,
|
lazy.from_eager,
|
||||||
lazy.to_polars().filter(filter_expr.to_polars()),
|
lazy.to_polars().filter(filter_expr.to_polars()),
|
||||||
);
|
);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame, NuLazyGroupBy},
|
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame, NuLazyGroupBy},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -153,7 +153,7 @@ fn command(
|
|||||||
) -> Result<PipelineData, ShellError> {
|
) -> Result<PipelineData, ShellError> {
|
||||||
let group_by = lazy.to_polars().group_by(expressions);
|
let group_by = lazy.to_polars().group_by(expressions);
|
||||||
let group_by = NuLazyGroupBy::new(group_by, lazy.from_eager, lazy.schema()?);
|
let group_by = NuLazyGroupBy::new(group_by, lazy.from_eager, lazy.schema()?);
|
||||||
to_pipeline_data(plugin, engine, call.head, group_by)
|
group_by.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -244,7 +244,8 @@ impl PluginCommand for LazyJoin {
|
|||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
let lazy = NuLazyFrame::new(from_eager, lazy);
|
let lazy = NuLazyFrame::new(from_eager, lazy);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/// All of these commands have an identical body and only require
|
/// All of these commands have an identical body and only require
|
||||||
/// to have a change in the name, description and function
|
/// to have a change in the name, description and function
|
||||||
use crate::dataframe::values::{Column, NuDataFrame, NuLazyFrame};
|
use crate::dataframe::values::{Column, NuDataFrame, NuLazyFrame};
|
||||||
use crate::values::{to_pipeline_data, CustomValueSupport};
|
use crate::values::CustomValueSupport;
|
||||||
use crate::PolarsPlugin;
|
use crate::PolarsPlugin;
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
use nu_protocol::{Category, Example, LabeledError, PipelineData, Signature, Span, Type, Value};
|
use nu_protocol::{Category, Example, LabeledError, PipelineData, Signature, Span, Type, Value};
|
||||||
@ -47,7 +47,8 @@ macro_rules! lazy_command {
|
|||||||
let lazy = NuLazyFrame::try_from_pipeline_coerce(plugin, input, call.head)
|
let lazy = NuLazyFrame::try_from_pipeline_coerce(plugin, input, call.head)
|
||||||
.map_err(LabeledError::from)?;
|
.map_err(LabeledError::from)?;
|
||||||
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().$func());
|
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().$func());
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +93,8 @@ macro_rules! lazy_command {
|
|||||||
let lazy = NuLazyFrame::try_from_pipeline_coerce(plugin, input, call.head)
|
let lazy = NuLazyFrame::try_from_pipeline_coerce(plugin, input, call.head)
|
||||||
.map_err(LabeledError::from)?;
|
.map_err(LabeledError::from)?;
|
||||||
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.into_polars().$func($ddot));
|
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.into_polars().$func($ddot));
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +162,8 @@ macro_rules! lazy_command {
|
|||||||
.map_err(LabeledError::from)?,
|
.map_err(LabeledError::from)?,
|
||||||
);
|
);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuLazyFrame},
|
dataframe::values::{Column, NuDataFrame, NuLazyFrame},
|
||||||
values::{
|
values::{
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, NuExpression, PolarsPluginObject,
|
cant_convert_err, CustomValueSupport, NuExpression, PolarsPluginObject, PolarsPluginType,
|
||||||
PolarsPluginType,
|
|
||||||
},
|
},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
@ -96,7 +95,7 @@ impl PluginCommand for LazyMedian {
|
|||||||
PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy),
|
PolarsPluginObject::NuLazyFrame(lazy) => command(plugin, engine, call, lazy),
|
||||||
PolarsPluginObject::NuExpression(expr) => {
|
PolarsPluginObject::NuExpression(expr) => {
|
||||||
let expr: NuExpression = expr.to_polars().median().into();
|
let expr: NuExpression = expr.to_polars().median().into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
_ => Err(cant_convert_err(
|
_ => Err(cant_convert_err(
|
||||||
&value,
|
&value,
|
||||||
@ -128,7 +127,7 @@ fn command(
|
|||||||
inner: vec![],
|
inner: vec![],
|
||||||
})?;
|
})?;
|
||||||
let lazy = NuLazyFrame::new(lazy.from_eager, polars_lazy);
|
let lazy = NuLazyFrame::new(lazy.from_eager, polars_lazy);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuLazyFrame},
|
dataframe::values::{Column, NuDataFrame, NuLazyFrame},
|
||||||
values::{
|
values::{
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, NuExpression, PolarsPluginObject,
|
cant_convert_err, CustomValueSupport, NuExpression, PolarsPluginObject, PolarsPluginType,
|
||||||
PolarsPluginType,
|
|
||||||
},
|
},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
@ -110,7 +109,7 @@ impl PluginCommand for LazyQuantile {
|
|||||||
.to_polars()
|
.to_polars()
|
||||||
.quantile(lit(quantile), QuantileInterpolOptions::default())
|
.quantile(lit(quantile), QuantileInterpolOptions::default())
|
||||||
.into();
|
.into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
_ => Err(cant_convert_err(
|
_ => Err(cant_convert_err(
|
||||||
&value,
|
&value,
|
||||||
@ -145,7 +144,7 @@ fn command(
|
|||||||
})?,
|
})?,
|
||||||
);
|
);
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
dataframe::values::{Column, NuDataFrame, NuExpression, NuLazyFrame},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,7 +68,8 @@ impl PluginCommand for LazySelect {
|
|||||||
let pipeline_value = input.into_value(call.head);
|
let pipeline_value = input.into_value(call.head);
|
||||||
let lazy = NuLazyFrame::try_from_value_coerce(plugin, &pipeline_value)?;
|
let lazy = NuLazyFrame::try_from_value_coerce(plugin, &pipeline_value)?;
|
||||||
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().select(&expressions));
|
let lazy = NuLazyFrame::new(lazy.from_eager, lazy.to_polars().select(&expressions));
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use super::super::values::NuLazyFrame;
|
use super::super::values::NuLazyFrame;
|
||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{Column, NuDataFrame, NuExpression},
|
dataframe::values::{Column, NuDataFrame, NuExpression},
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
values::CustomValueSupport,
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -144,7 +144,8 @@ impl PluginCommand for LazySortBy {
|
|||||||
lazy.to_polars()
|
lazy.to_polars()
|
||||||
.sort_by_exprs(&expressions, reverse, nulls_last, maintain_order),
|
.sort_by_exprs(&expressions, reverse, nulls_last, maintain_order),
|
||||||
);
|
);
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy).map_err(LabeledError::from)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
|
.map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -104,7 +101,7 @@ fn command(
|
|||||||
vec![Column::new("all_false".to_string(), vec![value])],
|
vec![Column::new("all_false".to_string(), vec![value])],
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -104,7 +101,7 @@ fn command(
|
|||||||
vec![Column::new("all_true".to_string(), vec![value])],
|
vec![Column::new("all_true".to_string(), vec![value])],
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -81,7 +78,7 @@ fn command(
|
|||||||
|
|
||||||
let res = chunked.into_series();
|
let res = chunked.into_series();
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -81,7 +78,7 @@ fn command(
|
|||||||
|
|
||||||
let res = chunked.into_series();
|
let res = chunked.into_series();
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -144,7 +141,7 @@ fn command(
|
|||||||
res.rename(&name);
|
res.rename(&name);
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{values::to_pipeline_data, PolarsPlugin};
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -97,5 +97,5 @@ fn command(
|
|||||||
res.rename("date");
|
res.rename("date");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -183,7 +180,7 @@ fn command(
|
|||||||
|
|
||||||
res.rename("datetime");
|
res.rename("datetime");
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -90,7 +87,7 @@ fn command(
|
|||||||
let res = casted.day().into_series();
|
let res = casted.day().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.hour().into_series();
|
let res = casted.hour().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
use polars::{prelude::NamedFrom, series::Series};
|
use polars::{prelude::NamedFrom, series::Series};
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
@ -80,7 +77,7 @@ fn command(
|
|||||||
let res = casted.minute().into_series();
|
let res = casted.minute().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.month().into_series();
|
let res = casted.month().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.nanosecond().into_series();
|
let res = casted.nanosecond().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.ordinal().into_series();
|
let res = casted.ordinal().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.second().into_series();
|
let res = casted.second().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.week().into_series();
|
let res = casted.week().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.weekday().into_series();
|
let res = casted.weekday().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::NuDataFrame;
|
use super::super::super::values::NuDataFrame;
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ fn command(
|
|||||||
let res = casted.year().into_series();
|
let res = casted.year().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -125,7 +122,7 @@ fn command(
|
|||||||
res.rename("arg_sort");
|
res.rename("arg_sort");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -103,7 +100,7 @@ fn command(
|
|||||||
})?
|
})?
|
||||||
.into();
|
.into();
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, res)
|
res.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
_ => Err(ShellError::UnsupportedInput {
|
_ => Err(ShellError::UnsupportedInput {
|
||||||
msg: "Expected the dataframe to have a column".to_string(),
|
msg: "Expected the dataframe to have a column".to_string(),
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -89,7 +86,7 @@ fn command(
|
|||||||
res.rename("arg_unique");
|
res.rename("arg_unique");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
use crate::{
|
use crate::{missing_flag_error, values::CustomValueSupport, PolarsPlugin};
|
||||||
missing_flag_error,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -212,7 +208,7 @@ fn command(
|
|||||||
}),
|
}),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, res)
|
res.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -118,7 +115,7 @@ fn command(
|
|||||||
res.rename("is_duplicated");
|
res.rename("is_duplicated");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -90,7 +87,7 @@ impl PluginCommand for IsNotNull {
|
|||||||
}
|
}
|
||||||
PolarsPluginObject::NuExpression(expr) => {
|
PolarsPluginObject::NuExpression(expr) => {
|
||||||
let expr: NuExpression = expr.to_polars().is_not_null().into();
|
let expr: NuExpression = expr.to_polars().is_not_null().into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
_ => Err(cant_convert_err(
|
_ => Err(cant_convert_err(
|
||||||
&value,
|
&value,
|
||||||
@ -115,7 +112,7 @@ fn command(
|
|||||||
res.rename("is_not_null");
|
res.rename("is_not_null");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
values::{
|
values::{
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, NuExpression, PolarsPluginObject,
|
cant_convert_err, CustomValueSupport, NuExpression, PolarsPluginObject, PolarsPluginType,
|
||||||
PolarsPluginType,
|
|
||||||
},
|
},
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
@ -90,7 +89,7 @@ impl PluginCommand for IsNull {
|
|||||||
}
|
}
|
||||||
PolarsPluginObject::NuExpression(expr) => {
|
PolarsPluginObject::NuExpression(expr) => {
|
||||||
let expr: NuExpression = expr.to_polars().is_null().into();
|
let expr: NuExpression = expr.to_polars().is_null().into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
_ => Err(cant_convert_err(
|
_ => Err(cant_convert_err(
|
||||||
&value,
|
&value,
|
||||||
@ -115,7 +114,7 @@ fn command(
|
|||||||
res.rename("is_null");
|
res.rename("is_null");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -118,7 +115,7 @@ fn command(
|
|||||||
res.rename("is_unique");
|
res.rename("is_unique");
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
use nu_plugin::{EngineInterface, EvaluatedCall, PluginCommand};
|
||||||
@ -88,7 +85,7 @@ fn command(
|
|||||||
let res = bool.not();
|
let res = bool.not();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
use crate::{
|
use crate::{missing_flag_error, values::CustomValueSupport, PolarsPlugin};
|
||||||
missing_flag_error,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -195,7 +191,7 @@ fn command(
|
|||||||
}),
|
}),
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, res)
|
res.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -78,7 +75,7 @@ fn command(
|
|||||||
vec![Column::new("count_null".to_string(), vec![value])],
|
vec![Column::new("count_null".to_string(), vec![value])],
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,7 +79,7 @@ impl PluginCommand for NUnique {
|
|||||||
}
|
}
|
||||||
PolarsPluginObject::NuExpression(expr) => {
|
PolarsPluginObject::NuExpression(expr) => {
|
||||||
let expr: NuExpression = expr.to_polars().n_unique().into();
|
let expr: NuExpression = expr.to_polars().n_unique().into();
|
||||||
to_pipeline_data(plugin, engine, call.head, expr)
|
expr.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
_ => Err(cant_convert_err(
|
_ => Err(cant_convert_err(
|
||||||
&value,
|
&value,
|
||||||
@ -120,7 +117,7 @@ fn command(
|
|||||||
vec![Column::new("count_unique".to_string(), vec![value])],
|
vec![Column::new("count_unique".to_string(), vec![value])],
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -181,7 +178,7 @@ fn command(
|
|||||||
res.rename(&name);
|
res.rename(&name);
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::values::{NuExpression, NuLazyFrame},
|
dataframe::values::{NuExpression, NuLazyFrame},
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -99,7 +96,7 @@ fn command_eager(
|
|||||||
let series = df.as_series(call.head)?.shift(period);
|
let series = df.as_series(call.head)?.shift(period);
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![series], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![series], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_lazy(
|
fn command_lazy(
|
||||||
@ -121,7 +118,7 @@ fn command_lazy(
|
|||||||
None => lazy.shift(shift).into(),
|
None => lazy.shift(shift).into(),
|
||||||
};
|
};
|
||||||
|
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -109,7 +106,7 @@ fn command(
|
|||||||
res.rename(series.name());
|
res.rename(series.name());
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -102,7 +99,7 @@ fn command(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
use crate::{
|
use crate::{missing_flag_error, values::CustomValueSupport, PolarsPlugin};
|
||||||
missing_flag_error,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -117,7 +113,7 @@ fn command(
|
|||||||
res.rename(series.name());
|
res.rename(series.name());
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
use crate::{
|
use crate::{missing_flag_error, values::CustomValueSupport, PolarsPlugin};
|
||||||
missing_flag_error,
|
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -119,7 +115,7 @@ fn command(
|
|||||||
res.rename(series.name());
|
res.rename(series.name());
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine_state, call.head, df)
|
df.to_pipeline_data(plugin, engine_state, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -83,7 +80,7 @@ fn command(
|
|||||||
let res = chunked.as_ref().str_len_bytes().into_series();
|
let res = chunked.as_ref().str_len_bytes().into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -132,7 +129,7 @@ fn command(
|
|||||||
.with_name(series.name());
|
.with_name(series.name());
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -101,7 +98,7 @@ fn command(
|
|||||||
.into_series();
|
.into_series();
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -88,7 +85,7 @@ fn command(
|
|||||||
res.rename(series.name());
|
res.rename(series.name());
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::super::values::{Column, NuDataFrame};
|
use super::super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -92,7 +89,7 @@ fn command(
|
|||||||
res.rename(series.name());
|
res.rename(series.name());
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
dataframe::{utils::extract_strings, values::NuLazyFrame},
|
dataframe::{utils::extract_strings, values::NuLazyFrame},
|
||||||
values::{
|
values::{cant_convert_err, CustomValueSupport, PolarsPluginObject, PolarsPluginType},
|
||||||
cant_convert_err, to_pipeline_data, CustomValueSupport, PolarsPluginObject,
|
|
||||||
PolarsPluginType,
|
|
||||||
},
|
|
||||||
PolarsPlugin,
|
PolarsPlugin,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,7 +115,7 @@ fn command_eager(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
let df = NuDataFrame::try_from_series_vec(vec![res.into_series()], call.head)?;
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn command_lazy(
|
fn command_lazy(
|
||||||
@ -148,7 +145,7 @@ fn command_lazy(
|
|||||||
} else {
|
} else {
|
||||||
lazy.unique_stable(subset, strategy).into()
|
lazy.unique_stable(subset, strategy).into()
|
||||||
};
|
};
|
||||||
to_pipeline_data(plugin, engine, call.head, lazy)
|
lazy.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
use crate::{
|
use crate::{values::CustomValueSupport, PolarsPlugin};
|
||||||
values::{to_pipeline_data, CustomValueSupport},
|
|
||||||
PolarsPlugin,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::super::values::{Column, NuDataFrame};
|
use super::super::values::{Column, NuDataFrame};
|
||||||
|
|
||||||
@ -90,7 +87,7 @@ fn command(
|
|||||||
})?;
|
})?;
|
||||||
|
|
||||||
let df: NuDataFrame = res.into();
|
let df: NuDataFrame = res.into();
|
||||||
to_pipeline_data(plugin, engine, call.head, df)
|
df.to_pipeline_data(plugin, engine, call.head)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
@ -302,44 +302,44 @@ pub trait CustomValueSupport: Cacheable {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// Wraps the cache and into_value calls.
|
/// Wraps the cache and into_value calls.
|
||||||
/// This function also does mapping back and forth
|
/// This function also does mapping back and forth
|
||||||
/// between lazy and eager values and makes sure they
|
/// between lazy and eager values and makes sure they
|
||||||
/// are cached appropriately.
|
/// are cached appropriately.
|
||||||
pub fn cache_and_to_value(
|
fn cache_and_to_value(
|
||||||
plugin: &PolarsPlugin,
|
self,
|
||||||
engine: &EngineInterface,
|
plugin: &PolarsPlugin,
|
||||||
span: Span,
|
engine: &EngineInterface,
|
||||||
cv: impl CustomValueSupport,
|
span: Span,
|
||||||
) -> Result<Value, ShellError> {
|
) -> Result<Value, ShellError> {
|
||||||
match cv.to_cache_value()? {
|
match self.to_cache_value()? {
|
||||||
// if it was from a lazy value, make it lazy again
|
// if it was from a lazy value, make it lazy again
|
||||||
PolarsPluginObject::NuDataFrame(df) if df.from_lazy => {
|
PolarsPluginObject::NuDataFrame(df) if df.from_lazy => {
|
||||||
let df = df.lazy();
|
let df = df.lazy();
|
||||||
Ok(df.cache(plugin, engine, span)?.into_value(span))
|
Ok(df.cache(plugin, engine, span)?.into_value(span))
|
||||||
|
}
|
||||||
|
// if it was from an eager value, make it eager again
|
||||||
|
PolarsPluginObject::NuLazyFrame(lf) if lf.from_eager => {
|
||||||
|
let lf = lf.collect(span)?;
|
||||||
|
Ok(lf.cache(plugin, engine, span)?.into_value(span))
|
||||||
|
}
|
||||||
|
_ => Ok(self.cache(plugin, engine, span)?.into_value(span)),
|
||||||
}
|
}
|
||||||
// if it was from an eager value, make it eager again
|
}
|
||||||
PolarsPluginObject::NuLazyFrame(lf) if lf.from_eager => {
|
|
||||||
let lf = lf.collect(span)?;
|
/// Caches the object, converts it to a it's CustomValue counterpart
|
||||||
Ok(lf.cache(plugin, engine, span)?.into_value(span))
|
/// And creates a pipeline data object out of it
|
||||||
}
|
#[inline]
|
||||||
_ => Ok(cv.cache(plugin, engine, span)?.into_value(span)),
|
fn to_pipeline_data(
|
||||||
|
self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
span: Span,
|
||||||
|
) -> Result<PipelineData, ShellError> {
|
||||||
|
Ok(PipelineData::Value(
|
||||||
|
self.cache_and_to_value(plugin, engine, span)?,
|
||||||
|
None,
|
||||||
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Caches the object, converts it to a it's CustomValue counterpart
|
|
||||||
/// And creates a pipeline data object out of it
|
|
||||||
#[inline]
|
|
||||||
pub fn to_pipeline_data(
|
|
||||||
plugin: &PolarsPlugin,
|
|
||||||
engine: &EngineInterface,
|
|
||||||
span: Span,
|
|
||||||
cv: impl CustomValueSupport,
|
|
||||||
) -> Result<PipelineData, ShellError> {
|
|
||||||
Ok(PipelineData::Value(
|
|
||||||
cache_and_to_value(plugin, engine, span, cv)?,
|
|
||||||
None,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user