Skip to content

"where" throws error when fields don't exist on all entries. #800

Closed

Description

@empath75

Is there a way to filter on the existence of a field?

nushell-0.3.0> cat testdata.json | from-json
━━━┯━━━━━┯━━━━━
 # │ foo │ baz
───┼─────┼─────
 0 │ bar │ bat
 1 │ bar │
━━━┷━━━━━┷━━━━━
nushell-0.3.0> cat testdata.json | from-json | where baz == bat
error: Unknown column
- shell:1:38
1 | cat testdata.json | from-json | where baz == bat
  |                                       ^^^ did you mean 'foo'?
nushell-0.3.0> cat testdata.json | from-json | where foo == bar
━━━┯━━━━━┯━━━━━
 # │ foo │ baz
───┼─────┼─────
 0 │ bar │ bat
 1 │ bar │
━━━┷━━━━━┷━━━━━
nushell-0.3.0> cat testdata.json
[{"foo":"bar", "baz": "bat"},{"foo":"bar"}]

Activity

  1. sophiajt commented on Oct 13, 2019

    @sophiajt
    Contributor

    There isn't a way to filter yet, but that's definitely something we should add.

  2. andrasio commented on Nov 2, 2019

    @andrasio
    Member
  3. added
    category:enhancement
    on Nov 2, 2019
  4. sophiajt commented on Apr 6, 2020

    @sophiajt
    Contributor

    You can now use default or compact to remove rows that are missing the column you're looking for. I'll go ahead and remove, though keeping eyes open that we may want to further improve this.

  5. added a commit that references this issue on Oct 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    category:enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions