forked from extern/nushell
Allow empty list inputs in group-by
and return empty record (#10730)
# Description Changed `group-by` behavior to accept empty list as input and return an empty record instead of throwing an error. I also replaced `errors_if_input_empty()` test to reflect the new expected behavior. See #10713 # User-Facing Changes `[] | group-by` or `[] | group-by a` now returns empty record # Tests + Formatting 1 test for emptied table i.e. list --------- Signed-off-by: Oscar <71343264+0scvr@users.noreply.github.com>
This commit is contained in:
@ -128,12 +128,9 @@ pub fn group_by(
|
||||
let values: Vec<Value> = input.into_iter().collect();
|
||||
|
||||
if values.is_empty() {
|
||||
return Err(ShellError::GenericError(
|
||||
"expected table from pipeline".into(),
|
||||
"requires a table input".into(),
|
||||
Some(span),
|
||||
return Ok(PipelineData::Value(
|
||||
Value::record(Record::new(), Span::unknown()),
|
||||
None,
|
||||
Vec::new(),
|
||||
));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user