where: more convenience handling nothing
Author: devurandomCreated Sep 11, 2026Updated Sep 13, 2026
Labelscategory:enhancementA:error-unhelpfulstatus:needs-triage
Basics
- I have done a basic search through the issue tracker to find similar or related issues.
- I have made myself familiar with the available features of Nushell for the particular area this enhancement request touches.
Related problem
I have trouble filtering a list based on a column that can be absent.
The most naive approach fails when the column is absent:
❯ [{a:[1] b:2} {b:2}] | where {|r| $r.a | where $it == 1 | is-not-empty }
Error: nu::shell::column_not_found
× Cannot find column 'a'
╭─[repl_entry #16:1:34]
1 │ [{a:[1] b:2} {b:2}] | where {|r| $r.a | where $it == 1 | is-not-empty }
· ─┬ ┬
· │ ╰── column 'a' is missing in one or more values
· ╰── value originates here
╰────
help: If some rows have this column, try using 'a?' for optional access, or pre-fill using the `default` commandFollowing the advice to add the question mark operator ? does not really help, because now where complains that nothing is not a list:
❯ [{a:[1] b:2} {b:2}] | where {|r| $r.a? | where $it == 1 | is-not-empty }
Error: nu::shell::only_supports_this_input_type
× Input type not supported.
╭─[repl_entry #15:1:37]
1 │ [{a:[1] b:2} {b:2}] | where {|r| $r.a? | where $it == 1 | is-not-empty }
· ┬ ──┬──
· │ ╰── only list<any>, table, and range input data is supported
· ╰── input type: nothing
╰────When also adding default from the first suggestion, it finally works:
❯ [{a:[1] b:2} {b:2}] | where {|r| $r.a? | default [] | where $it == 1 | is-not-empty }
# a b
0 0 1 2However:
- This is inconvenient and bulky, particularly assuming interactive use of nushell.
- If one starts at the 2nd form, there is no helpful recommendation.
- The recommendation on the first form is "or pre-fill", but I believe it should have been "and pre-fill", because
?alone does not solve the problem.
Describe the solution you'd like
- I would expect
where(and any other command takinglistas input) to also be able to handlenothingand treat it as the empty list[]. - I would expect
where(and others), whennothingas an unsupported input type is passed (in case this cannot be treated as the empty list), to recommend to usedefault. - The recommendation for
nu::shell::column_not_foundshould probably recommend the use of both?anddefault, not just either one of them.
Describe alternatives you've considered
No response
Additional context and details
| key | value |
|---|---|
| version | 0.115.1 |
| major | 0 |
| minor | 115 |
| patch | 1 |
| branch | |
| commit_hash | |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.97.1 (8bab26f4f 2026-07-14) (built from a source tarball) |
| cargo_version | cargo 1.97.0 (c980f4866 2026-06-30) |
| build_time | 1980-01-01 00:00:00 +00:00 |
| build_rust_channel | release |
| allocator | standard |
| features | default, helix, lsp, mcp, network, plugin, rustls-tls, sqlite, trash-support |
| installed_plugins | dns 4.0.12, formats 0.115.1, gstat 0.115.1, polars 0.115.1, query 0.115.1 |
| experimental_options | example=false, dc-glob=false, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=false, cell-path-types=false, background-completions=true |
Source: nushell/nushell