Skip to content

compact does not support nested cell paths #4274

Closed

Description

@lily-mara

Describe the bug

The select command uses ColumnPaths internally which allows users to write paths containing literal dots by surrounding these segments with quote characters. default and compact however treat their path inputs as strings split on each . and are thus incapable of such functionality. This limits their functionality when dealing with data files containing URLs for example. I ran into the issue when trying to clean up some data pertaining to a kubernetes cluster.

How to reproduce

❯ echo '[{ "labels": { "app.kubernetes.io/name": "my-great-app" } }, { "labels": {} }]' | from json | default labels.'app.kubernetes.io/name' unknown | select labels.'app.kubernetes.io/name'
───┬───────────────────────────────
 # │ labels_app_kubernetes_io/name 
───┼───────────────────────────────
 0 │ my-great-app                  
 1 │                               
───┴───────────────────────────────

Expected behavior

I would expect the above command to print unknown for the label value in row 1.

Screenshots

No response

Configuration

| Column0            | Column1                                                  |
| ------------------ | -------------------------------------------------------- |
| version            | 0.43.0                                                   |
| build_os           | macos-aarch64                                            |
| rust_version       | rustc 1.58.1 (db9d1b20b 2022-01-20)                      |
| rust_channel       | stable-aarch64-apple-darwin                              |
| cargo_version      | cargo 1.58.0 (f01b232bc 2022-01-19)                      |
| pkg_version        | 0.43.0                                                   |
| build_time         | 2022-01-21 17:16:49 -08:00                               |
| build_rust_channel | release                                                  |
| features           | ctrlc, dataframe, default, rustyline, term, which, zip   |
| installed_plugins  | chart bar, chart line, fetch, match, post, ps, sys, tree |

Additional context

No response

Activity

  1. added a commit that references this issue on Feb 5, 2022
    db69a1d
  2. fdncred commented on Feb 9, 2022

    @fdncred
    Contributor

    hey @lily-mara - engine-q is merged now into nushell/main. does this problem still exist? I see the output is a little different.

  3. lily-mara commented on Feb 9, 2022

    @lily-mara
    ContributorAuthor

    Yes, the issue is still present though the output is now slightly different.

    〉echo '[{ "labels": { "app.kubernetes.io/name": "my-great-app" } }, { "labels": {} }]' | from json | default labels.'app.kubernetes.io/name' unknown | select labels.'app.kubernetes.io/name'
    ╭───┬──────────────────────────────────────────────────────────────────────────────────╮
    │ # │                          labels.app.kubernetes.io/name                           │
    ├───┼──────────────────────────────────────────────────────────────────────────────────┤
    │ 0 │ my-great-app                                                                     │
    │ 1 │ CantFindColumn(Span { start: 3581, end: 3605 }, Span { start: 3505, end: 3514 }) │
    ╰───┴──────────────────────────────────────────────────────────────────────────────────╯
    

    I can try to take a pass at this now that engine-q is merged in.

  4. sophiajt commented on Aug 9, 2023

    @sophiajt
    Contributor

    This still repros in the latest main.

  5. added
    semantics
    on Aug 15, 2024
  6. weirdan commented on Feb 10, 2026

    @weirdan
    Contributor

    default doesn't take cell paths, only column names. Also the default arguments are in the wrong order (but maybe it was correct back then).

    Current approach is to use update col { default value subcolumn }:

    ❯ '[{ "labels": { "app.kubernetes.io/name": "my-great-app" } }, { "labels": {} }]'
    ⋮ | from json
    ⋮ | update labels { default unknown 'app.kubernetes.io/name' }
    ⋮ | select labels.'app.kubernetes.io/name'
    ╭───┬───────────────────────────────╮
    │ # │ labels.app.kubernetes.io/name │
    ├───┼───────────────────────────────┤
    │ 0 │ my-great-app                  │
    │ 1 │ unknown                       │
    ╰───┴───────────────────────────────╯
  7. kronberger-droid commented on Nov 13, 2026

    @kronberger-droid
    Contributor

    The default half got fixed by #19058.
    compact is still open on 0.117:

    [{labels: {c: 1}} {labels: {c: null}}] | compact labels.c
    

    returns an empty list, also dropping the row that has a value.
    I narrowed the title to compact.

  8. changed the title [-]`default` and `compact` do not support path segments containing literal dots[/-] [+]`compact` does not support nested cell paths[/+] on Nov 13, 2026
  9. added a commit that references this issue on Nov 21, 2026
    a661e23
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:bugsemantics

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions