add rename (#5534)

This commit is contained in:
WindSoilder 2022-05-13 19:47:11 +08:00 committed by GitHub
parent 65bac77e8a
commit 06f40405fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -112,6 +112,7 @@ fn rename(
let columns: Vec<String> = call.rest(engine_state, stack, 0)?;
let metadata = input.metadata();
let head_span = call.head;
input
.map(
move |item| match item {
@ -151,7 +152,13 @@ fn rename(
Value::Record { cols, vals, span }
}
x => x,
x => Value::Error {
error: ShellError::UnsupportedInput(
"can't rename: input is not table, so no column names available for rename"
.to_string(),
x.span().unwrap_or(head_span),
),
},
},
engine_state.ctrlc.clone(),
)

View File

@ -61,8 +61,6 @@ fn keeps_remaining_original_names_given_less_new_names_than_total_original_names
})
}
// FIXME: jt: needs more work
#[ignore]
#[test]
fn errors_if_no_columns_present() {
Playground::setup("rename_test_3", |dirs, sandbox| {