From 604025fe341ec5f0e97377f6a25f6de774ac26cb Mon Sep 17 00:00:00 2001 From: Fernando Herrera Date: Thu, 21 Jul 2022 10:42:12 +0100 Subject: [PATCH] append string to series (#6089) --- .../values/nu_dataframe/between_values.rs | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/crates/nu-command/src/dataframe/values/nu_dataframe/between_values.rs b/crates/nu-command/src/dataframe/values/nu_dataframe/between_values.rs index fb687fb42d..2603ddb521 100644 --- a/crates/nu-command/src/dataframe/values/nu_dataframe/between_values.rs +++ b/crates/nu-command/src/dataframe/values/nu_dataframe/between_values.rs @@ -226,6 +226,7 @@ pub(super) fn compute_series_single_value( Value::Float { val, .. } => { compute_series_decimal(&lhs, *val, >::add, lhs_span) } + Value::String { val, .. } => add_string_to_series(&lhs, val, lhs_span), _ => Err(ShellError::OperatorMismatch { op_span: operator.span, lhs_ty: left.get_type(), @@ -758,3 +759,22 @@ fn contains_series_pat(series: &Series, pat: &str, span: Span) -> Result Result { + let casted = series.utf8(); + match casted { + Ok(casted) => { + let res = casted + pat; + let res = res.into_series(); + + NuDataFrame::series_to_value(res, span) + } + Err(e) => Err(ShellError::GenericError( + "Unable to cast to string".into(), + e.to_string(), + Some(span), + None, + Vec::new(), + )), + } +}