make polars commands propagate metadata

This commit is contained in:
Julian Amarilla 2025-04-25 02:01:35 -03:00
parent bc946f012a
commit b8e6dde4ff
9 changed files with 126 additions and 0 deletions

View File

@ -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)? {

View File

@ -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);

View File

@ -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)? {

View File

@ -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)? {

View File

@ -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)
} }

View File

@ -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)? {

View File

@ -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")?;

View File

@ -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();

View File

@ -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)? {