mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 18:34:31 +02:00
fix cannot find issue when performing collect on an eager dataframe (#15577)
# Description Performing a `polars collect` on an eager dataframe should be a no-op operation. However, when used with a pipeline and not saving to a value a cache error occurs. This addresses that cache error.
This commit is contained in:
@ -5,7 +5,9 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
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, ShellError, Signature, Span, Type, Value,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct LazyCollect;
|
pub struct LazyCollect;
|
||||||
@ -78,13 +80,21 @@ impl PluginCommand for LazyCollect {
|
|||||||
// This should just increment the cache value.
|
// This should just increment the cache value.
|
||||||
// We can return a value back without incrementing the
|
// We can return a value back without incrementing the
|
||||||
// cache value or the value will be dropped (issue #12828)
|
// cache value or the value will be dropped (issue #12828)
|
||||||
let _ = plugin.cache.get(&df.id, true)?;
|
let cv =
|
||||||
|
plugin
|
||||||
|
.cache
|
||||||
|
.get(&df.id, true)?
|
||||||
|
.ok_or_else(|| ShellError::GenericError {
|
||||||
|
error: format!("Failed to get cached value {}", df.id),
|
||||||
|
msg: "".into(),
|
||||||
|
span: Some(call.head),
|
||||||
|
help: None,
|
||||||
|
inner: vec![],
|
||||||
|
})?;
|
||||||
|
let df = NuDataFrame::from_cache_value(cv.value.clone())?;
|
||||||
|
|
||||||
// just return the dataframe, add to cache again to be safe
|
// just return the dataframe, add to cache again to be safe
|
||||||
Ok(PipelineData::Value(
|
Ok(PipelineData::Value(df.into_value(call.head), None))
|
||||||
df.cache(plugin, engine, call.head)?.into_value(call.head),
|
|
||||||
None,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
_ => Err(cant_convert_err(
|
_ => Err(cant_convert_err(
|
||||||
&value,
|
&value,
|
||||||
|
Reference in New Issue
Block a user