zed icon indicating copy to clipboard operation
zed copied to clipboard

coerce key in map lookup

Open mccanne opened this issue 4 years ago • 1 comments

Right now, map lookups return missing if the lookup value does not exactly match the type of the map key. This should be more robust with coercion etc.

mccanne avatar Dec 21 '21 17:12 mccanne

Here's my attempt at a repro with Zed commit 7396ea9.

$ cat repro.zson 
{
    m: |{
        1: "a",
        2: "b",
        3: "c" 
    }|
}

$ zq -version
Version: v1.2.0-97-g7396ea9c

$ zq -Z 'yield m[2]' repro.zson
"b"

$ zq -Z 'yield m[2.0]' repro.zson
error("missing")

$ zq -Z 'yield m[uint64(2)]' repro.zson
error("missing")

I found what looks like a separate map bug while reproducing this one, so I've opened #4167 to track it.

philrz avatar Aug 29 '22 17:08 philrz