diff --git a/crates/nu-command/src/filters/select.rs b/crates/nu-command/src/filters/select.rs index 9a62565dec..d06f14ca8d 100644 --- a/crates/nu-command/src/filters/select.rs +++ b/crates/nu-command/src/filters/select.rs @@ -214,18 +214,13 @@ fn select( Vec::new(), )); } - if unique_rows.contains(val) { - return Err(ShellError::GenericError( - "Select can't get the same row twice".into(), - "duplicated row index".into(), - Some(*span), - None, - Vec::new(), - )); - } unique_rows.insert(*val); } - _ => new_columns.push(column), + _ => { + if !new_columns.contains(&column) { + new_columns.push(column) + } + } }; } let columns = new_columns; diff --git a/crates/nu-command/tests/commands/select.rs b/crates/nu-command/tests/commands/select.rs index 900a70ab0c..d44fc54391 100644 --- a/crates/nu-command/tests/commands/select.rs +++ b/crates/nu-command/tests/commands/select.rs @@ -218,10 +218,17 @@ fn select_failed3() { } #[test] -fn select_failed4() { - let actual = nu!("[{a: 1 b: 10}, {a:2, b:11}] | select 0 0"); +fn select_repeated_rows() { + let actual = nu!("[[a b c]; [1 2 3] [4 5 6] [7 8 9]] | select 0 0 | to nuon"); - assert!(actual.err.contains("Select can't get the same row twice")); + assert_eq!(actual.out, "[[a, b, c]; [1, 2, 3]]"); +} + +#[test] +fn select_repeated_column() { + let actual = nu!("[[a b c]; [1 2 3] [4 5 6] [7 8 9]] | select a a | to nuon"); + + assert_eq!(actual.out, "[[a]; [1], [4], [7]]"); } #[test]