-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Select column cannot find column when parsing json that is missing keys #6969
Copy link
Copy link
Closed
Labels
category:bugSomething isn't workingSomething isn't workingcategory:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedBehavior between different commands or types inconsistent/unexpected
Milestone
Description
Describe the bug
Consider the following json
> let versions = '[
{
"version": "v2.1.0",
"features": "test"
},
{
"version": "v2.1.1"
}
]'We can run the following shell to get a list of features
> $versions | from json | get features
╭───┬──────╮
│ 0 │ test │
│ 1 │ │
╰───┴──────╯But we cannot select the features column
> $versions | from json | select features
Error: nu::shell::column_not_found (link)
× Cannot find column
╭─[entry #234:1:1]
1 │ $versions | from json | select features
· ────┬──── ────┬───
· │ ╰── cannot find column
· ╰── value originates here
╰────Note, we can select features if we first do a sort-by
> $versions | from json | sort-by version | select features
╭───┬──────────╮
│ # │ features │
├───┼──────────┤
│ 0 │ test │
│ 1 │ │
╰───┴──────────╯How to reproduce
- Create a table using the following line:
let versions = ('[{"version": "v2.1.0", "features": "test"}, {"version": "v2.1.1" }]' | from json) - Try to select the features column
$versions | select features - Notice that it errored with
Error: nu::shell::column_not_found
Expected behavior
I expect nu to find the column because it looks like it has the column in the table display view, and it can get the column as a list
Screenshots
No response
Configuration
version | transpose key value | to md --pretty
| key | value |
|---|---|
| version | 0.70.0 |
| branch | |
| commit_hash | |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.63.0 (4b91a6ea7 2022-08-08) |
| rust_channel | stable-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.63.0 (fd9c4297c 2022-07-01) |
| pkg_version | 0.70.0 |
| build_time | 2022-11-01 10:11:57 -04:00 |
| build_rust_channel | release |
| features | database, dataframe, default, trash, which, zip |
| installed_plugins |
Additional context
This works if you use either of these json's:
[
{
"version": "v2.1.0",
"features": "test"
},
{
"version": "v2.1.1",
"features": "hi"
}
][
{
"version": "v2.1.0",
"features": "test"
},
{
"version": "v2.1.1",
"features": null
}
]Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
category:bugSomething isn't workingSomething isn't workingcategory:inconsistent-behaviorBehavior between different commands or types inconsistent/unexpectedBehavior between different commands or types inconsistent/unexpected