Update description and error types for split-by#10865
Update description and error types for split-by#10865sholderbach merged 4 commits intonushell:mainfrom
split-by#10865Conversation
`split-by` only works on a `Record`, the error was updated to match, and now uses a more-specific type The `usage` was updated to say "record" as well
sholderbach
left a comment
There was a problem hiding this comment.
Thanks for improving the messages here!
|
Wait, split-by doesn't work on tables? I thought all the blah-by commands did? |
PS: I'm unclear on what the difference between |
|
ya, I've never used > {
'2019': [
{ name: 'andres', lang: 'rb', year: '2019' },
{ name: 'jt', lang: 'rs', year: '2019' }
],
'2021': [
{ name: 'storm', lang: 'rs', 'year': '2021' }
]
} | split-by lang
╭──┬─────────────────╮
│rb│{record 1 field} │
│rs│{record 2 fields}│
╰──┴─────────────────╯There are other |
|
sounds good 👌 |
|
Looking at the example some more after playing around with input_output_types() in this command, I'm wondering if the only way this command works is if it's a record with tables as values? I'd love to see more examples in the help of how this command works. |
fdncred
left a comment
There was a problem hiding this comment.
Thanks for working on this error.
| Vec::new(), | ||
| )) | ||
| } | ||
| _ => return Err(ShellError::PipelineEmpty { dst_span }), |
There was a problem hiding this comment.
If I read the code leading to this point correctly this could still be more than PipelineData::Empty e.g. an ExternalStream, right?
There was a problem hiding this comment.
Yes. In 84661a5 I split PipelineData::Empty out from the other types which return a PipelineMismatch. I looked around and this seems most appropriate as merge treats a ListStream as a List and ExternalStream currently can't produce a Record.
|
@drbrain Are you still looking into this? |
Neither of these pipeline types produce a single Record which is all split-by can handle.
|
I had a busy week. It should be ready to go with 84661a5 |
sholderbach
left a comment
There was a problem hiding this comment.
Awesome thanks, this looks good and well covered
# Description `split-by` only works on a `Record`, the error type was updated to match, and now uses a more-specific type. (Two type fixes for the price of one!) The `usage` was updated to say "record" as well # User-Facing Changes * Providing the wrong type to `split-by` now gives an error messages with the correct required input type Previously: ``` ❯ ls | get name | split-by type Error: × unsupported input ╭─[entry nushell#267:1:1] 1 │ ls | get name | split-by type · ─┬─ · ╰── requires a table with one row for splitting ╰──── ``` With this PR: ``` ❯ ls | get name | split-by type Error: nu:🐚:type_mismatch × Type mismatch. ╭─[entry #1:1:1] 1 │ ls | get name | split-by type · ─┬─ · ╰── requires a record to split ╰──── ``` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting Only generated commands need to be updated --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
# Description `split-by` only works on a `Record`, the error type was updated to match, and now uses a more-specific type. (Two type fixes for the price of one!) The `usage` was updated to say "record" as well # User-Facing Changes * Providing the wrong type to `split-by` now gives an error messages with the correct required input type Previously: ``` ❯ ls | get name | split-by type Error: × unsupported input ╭─[entry nushell#267:1:1] 1 │ ls | get name | split-by type · ─┬─ · ╰── requires a table with one row for splitting ╰──── ``` With this PR: ``` ❯ ls | get name | split-by type Error: nu:🐚:type_mismatch × Type mismatch. ╭─[entry nushell#1:1:1] 1 │ ls | get name | split-by type · ─┬─ · ╰── requires a record to split ╰──── ``` # Tests + Formatting - 🟢 `toolkit fmt` - 🟢 `toolkit clippy` - 🟢 `toolkit test` - 🟢 `toolkit test stdlib` # After Submitting Only generated commands need to be updated --------- Co-authored-by: Darren Schroeder <343840+fdncred@users.noreply.github.com>
Description
split-byonly works on aRecord, the error type was updated to match, and now uses a more-specific type. (Two type fixes for the price of one!)The
usagewas updated to say "record" as wellUser-Facing Changes
split-bynow gives an error messages with the correct required input typePreviously:
With this PR:
Tests + Formatting
toolkit fmttoolkit clippytoolkit testtoolkit test stdlibAfter Submitting
Only generated commands need to be updated