use nu_protocol::Value; use std::collections::HashSet; pub fn get_columns(input: &[Value]) -> Vec { let mut columns = vec![]; for item in input { let Value::Record { cols, .. } = item else { return vec![]; }; for col in cols { if !columns.contains(col) { columns.push(col.to_string()); } } } columns } // If a column doesn't exist in the input, return it. pub fn nonexistent_column(inputs: Vec, columns: Vec) -> Option { let set: HashSet = HashSet::from_iter(columns.iter().cloned()); for input in &inputs { if set.contains(input) { continue; } return Some(input.clone()); } None }