nushell.github.io
nushell.github.io copied to clipboard
Document why `get` is strict and errors on blanks
originally from https://github.com/nushell/nushell/issues/3193
We may want to look into this deeper. get
does need to be strict (it's not fully strict). I believe it is strict
for rows that have missing columns. However, if all rows have the column of interest present and one of them is $nothing
, get
will happily ignore it.
This should error (but it's not):
> echo [[a]; [$nothing] [value]] | get a
value
the user should see the error showing up and fix like so:
> echo [[a]; [$nothing] [value]] | compact | get a
value
> echo [[a]; [$nothing] [value]] | default a some_value | get a
───┬────────────
0 │ some_value
1 │ value
───┴────────────
needs more investigation.
I believe this can be closed. The current behavior is now documented in a combination of the nothing
type and Navigating and Accessing Structured Data - Handling Missing Data, which is that;
- A missing value is different than a
null
/nothing
value -
get
will error on a missing value -
get
will not error when a result has anull
-
default
can be used to convert both *missingand
nothing` values to another value - The optional operator
?
can be used to return anull
in place of a missing value