You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New optional cell-path make use of variables harder #8480
Thanks for the detailed issue! It's really nice to get feedback like this during the development cycle.
Using variables in cell paths is something I didn't explore quite enough. I agree that using try/catch is a little awkward. FWIW, you can drop the parens in the try and do {"a": 1} | try {get $b} catch {null}, but that's not a huge improvement.
A few people have been exploring an into cellpath command that would convert a string to a cell path exactly the same way the parser does. With that, you could do something like:
let b = "b?" | into cellpath
{"a": 1} | get $b
The into cellpath would parse the b? and note that the b path member is optional. I'm wondering whether that would meet your needs.
Another option would be to just bring back the -i flag. I was thinking it wouldn't be needed after the ? change, but I wasn't considering the use of variables.
Say the b variable is a cell path with multiple members, foo.bar.baz (this can't be done right now because the relationship between strings and cell paths is only half baked, but let's pretend it can). In that case, what behaviour do you expect for get $b?? Do you expect it to make every path member optional, i.e. something equivalent to get foo?.bar?.baz??
having -i and ? feels a bit wrong.
I initially thought so, but I've come around to the view that it's useful to have a quick way to make every member in the cell path optional. i.e. get foo?.bar?.baz? would be equivalent to get -i foo.bar.baz.
Activity
rgwood commentedon Mar 16, 2023
Thanks for the detailed issue! It's really nice to get feedback like this during the development cycle.
Using variables in cell paths is something I didn't explore quite enough. I agree that using try/catch is a little awkward. FWIW, you can drop the parens in the
tryand do{"a": 1} | try {get $b} catch {null}, but that's not a huge improvement.A few people have been exploring an
into cellpathcommand that would convert a string to a cell path exactly the same way the parser does. With that, you could do something like:The
into cellpathwould parse theb?and note that thebpath member is optional. I'm wondering whether that would meet your needs.rgwood commentedon Mar 16, 2023
Another option would be to just bring back the
-iflag. I was thinking it wouldn't be needed after the?change, but I wasn't considering the use of variables.rgwood commentedon Mar 16, 2023
Say the
bvariable is a cell path with multiple members,foo.bar.baz(this can't be done right now because the relationship between strings and cell paths is only half baked, but let's pretend it can). In that case, what behaviour do you expect forget $b?? Do you expect it to make every path member optional, i.e. something equivalent toget foo?.bar?.baz??I initially thought so, but I've come around to the view that it's useful to have a quick way to make every member in the cell path optional. i.e.
get foo?.bar?.baz?would be equivalent toget -i foo.bar.baz.rgwood commentedon Mar 16, 2023
Cool, I'll re-add
-isoon.Add `-i` flag back to `get` and `select` (#8488)
rgwood commentedon Mar 16, 2023
Fixed in #8488