fixing cache drop issues on pivot

This commit is contained in:
Jack Wright 2024-07-02 09:01:49 -07:00
parent a467939f67
commit 53b3831a9d
2 changed files with 5 additions and 2 deletions

View File

@ -9,7 +9,7 @@ use polars_ops::pivot::pivot;
use crate::{
dataframe::values::utils::convert_columns_string,
values::{CustomValueSupport, PolarsPluginObject},
PolarsPlugin,
Cacheable, PolarsPlugin,
};
use super::super::values::NuDataFrame;
@ -126,7 +126,8 @@ fn command_eager(
})?;
let res = NuDataFrame::new(false, pivoted);
res.to_pipeline_data(plugin, engine, call.head)
res.cache(plugin, engine, call.head)?
.to_pipeline_data(plugin, engine, call.head)
}
fn check_column_datatypes<T: AsRef<str>>(

View File

@ -3,6 +3,7 @@ use std::cmp::Ordering;
use cache::cache_commands;
pub use cache::{Cache, Cacheable};
use dataframe::{stub::PolarsCmd, values::CustomValueType};
use log::debug;
use nu_plugin::{EngineInterface, Plugin, PluginCommand};
mod cache;
@ -72,6 +73,7 @@ impl Plugin for PolarsPlugin {
engine: &EngineInterface,
custom_value: Box<dyn CustomValue>,
) -> Result<(), LabeledError> {
debug!("cache_value_dropped called {:?}", custom_value);
if !self.disable_cache_drop {
let id = CustomValueType::try_from_custom_value(custom_value)?.id();
let _ = self.cache.remove(engine, &id, false);