mirror of
https://github.com/nushell/nushell.git
synced 2025-05-10 04:54:28 +02:00
make polars commands propagate metadata
This commit is contained in:
parent
bc946f012a
commit
b8e6dde4ff
@ -60,6 +60,20 @@ impl PluginCommand for ExprAggGroups {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExprAggGroups {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let value = input.into_value(call.head)?;
|
let value = input.into_value(call.head)?;
|
||||||
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
||||||
|
@ -126,6 +126,20 @@ impl PluginCommand for LazyAggregate {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LazyAggregate {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let vals: Vec<Value> = call.rest(0)?;
|
let vals: Vec<Value> = call.rest(0)?;
|
||||||
let value = Value::list(vals, call.head);
|
let value = Value::list(vals, call.head);
|
||||||
|
@ -55,6 +55,20 @@ impl PluginCommand for ExprCount {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExprCount {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let value = input.into_value(call.head)?;
|
let value = input.into_value(call.head)?;
|
||||||
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
||||||
|
@ -52,6 +52,20 @@ impl PluginCommand for ExprImplode {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExprImplode {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let value = input.into_value(call.head)?;
|
let value = input.into_value(call.head)?;
|
||||||
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
||||||
|
@ -111,6 +111,20 @@ impl PluginCommand for Summary {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Summary {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
command(plugin, engine, call, input).map_err(LabeledError::from)
|
command(plugin, engine, call, input).map_err(LabeledError::from)
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,20 @@ impl PluginCommand for FirstDF {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FirstDF {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let value = input.into_value(call.head)?;
|
let value = input.into_value(call.head)?;
|
||||||
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
||||||
|
@ -240,6 +240,20 @@ impl PluginCommand for LazyJoin {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LazyJoin {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let left = call.has_flag("left")?;
|
let left = call.has_flag("left")?;
|
||||||
let full = call.has_flag("full")?;
|
let full = call.has_flag("full")?;
|
||||||
|
@ -55,6 +55,20 @@ impl PluginCommand for ExprLen {
|
|||||||
plugin: &Self::Plugin,
|
plugin: &Self::Plugin,
|
||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ExprLen {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
_input: PipelineData,
|
_input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let res: NuExpression = polars::prelude::len().into();
|
let res: NuExpression = polars::prelude::len().into();
|
||||||
|
@ -116,6 +116,20 @@ impl PluginCommand for StrSlice {
|
|||||||
engine: &EngineInterface,
|
engine: &EngineInterface,
|
||||||
call: &EvaluatedCall,
|
call: &EvaluatedCall,
|
||||||
input: PipelineData,
|
input: PipelineData,
|
||||||
|
) -> Result<PipelineData, LabeledError> {
|
||||||
|
let metadata = input.metadata();
|
||||||
|
self.run_inner(plugin, engine, call, input)
|
||||||
|
.map(|pd| pd.set_metadata(metadata))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StrSlice {
|
||||||
|
fn run_inner(
|
||||||
|
&self,
|
||||||
|
plugin: &PolarsPlugin,
|
||||||
|
engine: &EngineInterface,
|
||||||
|
call: &EvaluatedCall,
|
||||||
|
input: PipelineData,
|
||||||
) -> Result<PipelineData, LabeledError> {
|
) -> Result<PipelineData, LabeledError> {
|
||||||
let value = input.into_value(call.head)?;
|
let value = input.into_value(call.head)?;
|
||||||
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
match PolarsPluginObject::try_from_value(plugin, &value)? {
|
||||||
|
Loading…
Reference in New Issue
Block a user