zui icon indicating copy to clipboard operation
zui copied to clipboard

Inspector renders null and {} both as "null"

Open philrz opened this issue 1 year ago • 2 comments

Repro is with Brim commit 55d1fdc.

Consider the following test data empties.ndjson:

{"empty_object": {}}
{"null_value": null}

When output by Zed CLI tooling, the different nature of the two values is preserved.

$ zq -version
Version: v1.2.0-7-g39539336

$ zq -Z empties.ndjson 
{
    empty_object: {}
}
{
    null_value: null
}

However, when rendered in the Inspector, both values end up looking the same.

image

philrz avatar Jul 20 '22 21:07 philrz

Also, I'm not sure if this is related, but the attached video shows no hover text in the Table view when rendering the empty_object. Like in #2453, I'm not certain if the Table view should just bail entirely on trying to render any of this.

https://user-images.githubusercontent.com/5934157/180090021-4f29c5ce-e484-42ce-a57d-0867ecd758ca.mp4

When the primary issue here gets fixed, if this remains as a problem, I'll open a separate issue.

philrz avatar Jul 20 '22 22:07 philrz

This is great. Thanks for tracking this.

jameskerr avatar Jul 21 '22 16:07 jameskerr

I happened to encounter this issue again and rechecked how things are looking now in the era of the redesigned Table at Brim commit 1e0a608.

As it shows, when shown as multiple shapes, the test data from empties.ndjson shows both vales as null, which is unsurprising since the Table view has taken on some behaviors of the Inspector view in this multi-shape context, so that bug remains. A separate new-ish behavior shown is when I do head 1 | yield empty_object to output just the {} value the table view is effectively completely blank, i.e., there's not even a this column header shown like when we do tail 1 | yield null_value.

https://user-images.githubusercontent.com/5934157/216714703-3ee1d7c5-3fd9-4f8d-a958-b54f17b310f7.mp4

philrz avatar Feb 03 '23 21:02 philrz

I was testing the Preview & Load branch, running through the steps in the zq tutorial using the new workflow. This reminded me how this issue is still with us, since the output given here by the CLI tooling is {} (which is what would be the correct output, not null). I'm going to push this issue into the backlog in hopes we can address it before the next GA release.

image

philrz avatar Oct 04 '23 22:10 philrz

The changes in linked PR #2875 thankfully have addressed this for the specific example shown above. Repeating the repro steps at Zui commit b90a400, we now see:

image

However, when I opened this issue I mistakenly thought it was something general to handling of null vs. {} in all contexts as opposed to on a per-complex-Zed-type basis. This led me to check the other types and indeed it looks like the same exposure exists elsewhere. This input data shows values inside an array, a set, a map, and also the top-level primitive values.

$ zq -Z empties2.ndjson 
{
    r: [
        {},
        null ({})
    ]
}
{
    s: |[
        null ({}),
        {}
    ]|
}
{
    m: |{
        "APPL": null ({}),
        "GOOG": {}
    }|
}
{}
null

Rendered in Zui at commit b90a400, we see the problem does indeed remain for the other complex types, though the top-level primitive ones look fine.

image

philrz avatar Nov 02 '23 19:11 philrz

Verified in Zui commit d29e674.

The second set of values highlighted in the comment above are now being rendered similar to ZSON.

image

A wider discussion about possible divergence between ZSON presentation and Zui's ZSON-like rendering similar to what's been tracked in this issue has led to the opening of #2880 to track a more automated approach we may use one day to sniff out other not-yet-found examples of problems like this and keep us from regressing.

Thanks @jameskerr!

philrz avatar Nov 07 '23 19:11 philrz