From 98369985b1252fe18cd50c0f87d38c09d7fb474a Mon Sep 17 00:00:00 2001
From: Jack Wright <56345+ayax79@users.noreply.github.com>
Date: Mon, 13 May 2024 16:17:31 -0700
Subject: [PATCH] Allow custom value operations to work on eager and lazy
dataframes interchangeably. (#12819)
Fixes Bug #12809
The example that @maxim-uvarov posted now works as expected:
---
.../values/nu_dataframe/operations.rs | 2 +-
.../values/nu_lazyframe/custom_value.rs | 48 +++++++++++++++++--
2 files changed, 44 insertions(+), 6 deletions(-)
diff --git a/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/operations.rs b/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/operations.rs
index 42d803b0e4..db5409aff2 100644
--- a/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/operations.rs
+++ b/crates/nu_plugin_polars/src/dataframe/values/nu_dataframe/operations.rs
@@ -27,7 +27,7 @@ impl NuDataFrame {
let rhs_span = right.span();
match right {
Value::Custom { .. } => {
- let rhs = NuDataFrame::try_from_value(plugin, right)?;
+ let rhs = NuDataFrame::try_from_value_coerce(plugin, right, rhs_span)?;
match (self.is_series(), rhs.is_series()) {
(true, true) => {
diff --git a/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/custom_value.rs b/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/custom_value.rs
index 731d210dd8..b3cd9500dd 100644
--- a/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/custom_value.rs
+++ b/crates/nu_plugin_polars/src/dataframe/values/nu_lazyframe/custom_value.rs
@@ -7,7 +7,7 @@ use uuid::Uuid;
use crate::{
values::{CustomValueSupport, NuDataFrame, PolarsPluginCustomValue},
- PolarsPlugin,
+ Cacheable, PolarsPlugin,
};
use super::NuLazyFrame;
@@ -76,11 +76,49 @@ impl PolarsPluginCustomValue for NuLazyFrameCustomValue {
_engine: &EngineInterface,
other_value: Value,
) -> Result