zed icon indicating copy to clipboard operation
zed copied to clipboard

is() doesn't handle dynamic type names

Open mccanne opened this issue 4 years ago • 1 comments

If a type name changes, is() should be able to match the different instances of the same name, e.g.,

% zq in.zson
{a:1}(=a)
{b:2}(=a)
{a:3}(=a)
% zq "is(type(a))" in.zson
{a:1}(=a)
{a:3}(=a)

zq should print all three records instead of just the one that matches the first type signature.

mccanne avatar Nov 05 '21 19:11 mccanne

Here's an interesting development. It looks like this got fixed some time ago, and was working as originally desired as recently as Zed commit cd2f3a3 on July 25, 2022.

$ zq -version
Version: v1.2.0-11-gcd2f3a37

$ zq "is(<a>)" in.zson
{a:1}(=a)
{b:2}(=a)
{a:3}(=a)

However, it broke again in the next commit cf7fe37 which is associated with #4030, though the erroneous output is different than flagged when the issue was first opened.

$ zq -version
Version: v1.2.0-12-gcf7fe37e

$ zq "is(<a>)" in.zson
{a:1}(=a)
{b:2}(=a)

philrz avatar Jul 27 '22 16:07 philrz

Verified in Zed commit 520b145.

We can see this was fixed by the changes in #4078. Starting with Zed commit 520b145 that had the changes from that PR, all three records now appear in the output.

$ zq -version
Version: v1.2.0-48-g520b145a

$ zq "is(<a>)" in.zson
{a:1}(=a)
{b:2}(=a)
{a:3}(=a)

Thanks @nwt!

philrz avatar Oct 25 '22 21:10 philrz