mirror of
https://github.com/nushell/nushell.git
synced 2024-12-23 15:39:06 +01:00
append string to series (#6089)
This commit is contained in:
parent
98126e2981
commit
604025fe34
@ -226,6 +226,7 @@ pub(super) fn compute_series_single_value(
|
|||||||
Value::Float { val, .. } => {
|
Value::Float { val, .. } => {
|
||||||
compute_series_decimal(&lhs, *val, <ChunkedArray<Float64Type>>::add, lhs_span)
|
compute_series_decimal(&lhs, *val, <ChunkedArray<Float64Type>>::add, lhs_span)
|
||||||
}
|
}
|
||||||
|
Value::String { val, .. } => add_string_to_series(&lhs, val, lhs_span),
|
||||||
_ => Err(ShellError::OperatorMismatch {
|
_ => Err(ShellError::OperatorMismatch {
|
||||||
op_span: operator.span,
|
op_span: operator.span,
|
||||||
lhs_ty: left.get_type(),
|
lhs_ty: left.get_type(),
|
||||||
@ -758,3 +759,22 @@ fn contains_series_pat(series: &Series, pat: &str, span: Span) -> Result<Value,
|
|||||||
)),
|
)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn add_string_to_series(series: &Series, pat: &str, span: Span) -> Result<Value, ShellError> {
|
||||||
|
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(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user