Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/structs/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,8 +1258,8 @@ impl ColumnSelection for Table {
let all_fields: Vec<Arc<Field>> = self.cols.iter().map(|fa| fa.field.clone()).collect();
let col_indices = selection.resolve_fields(&all_fields);

// If selecting all columns, create a full view without filtering
if col_indices.len() == all_fields.len() {
// If selecting all columns in table order, create a full view without filtering
if col_indices.iter().copied().eq(0..all_fields.len()) {
return TableV {
name: self.name.clone(),
fields: all_fields,
Expand Down Expand Up @@ -1577,6 +1577,19 @@ mod tests {
}
}

#[cfg(all(feature = "views", feature = "select"))]
#[test]
fn test_column_selection_of_every_column_keeps_the_selection_order() {
let mut t = Table::new_empty();
t.add_col(fa_i32!("ints", 1, 2));
t.add_col(fa_bool!("bools", true, false));

let view = t.c(vec!["bools", "ints"]);
let names: Vec<&str> = view.fields.iter().map(|f| f.name.as_str()).collect();
assert_eq!(names, ["bools", "ints"]);
assert!(matches!(&view.col_ix(0).unwrap().array, Array::BooleanArray(_)));
}

#[test]
#[should_panic(expected = "Column length mismatch")]
fn test_column_length_mismatch_panics() {
Expand Down
Loading