zui icon indicating copy to clipboard operation
zui copied to clipboard

Bugs with rendering of named types

Open philrz opened this issue 2 years ago • 1 comments

tl;dr

Named types are currently being rendered in Zui with extra parens (e.g., port=(uint16)) but in the Zed tooling this has been simplified to drop those (e.g., port=uint16).

Update: In the time since this issue was first opened, we've spotted some additional bugs with the rendering of named types. See the comment below for details.

Details

Repro is with Zui commit b413f0c.

https://github.com/brimdata/zed/pull/5000#pullrequestreview-1834736860 includes a summary of when we changed the ZSON syntax for named types and only recently updated the docs to reflect this. This is another whack-a-mole case such as described in https://github.com/brimdata/zui/issues/2880.

The attached video shows the current difference between Zui's presentation and that of the Zed tooling using this input data.zson:

{p1:80 (port=uint16), p2: 8080 (port)}

https://github.com/brimdata/zui/assets/5934157/2d220780-ea68-4d7f-9e35-095a19be03ad

If a user were to cut & paste the current ZSON-like text out of Zui and try to use it as ZSON input data, it would cause an error.

$ zq -version
Version: v1.12.0-41-g9e952f36

$ echo '{ p1: 80 ( port=(uint16)) , p2: 8080 ( port=(uint16)) }' | zq -i zson -
stdio:stdin: parse error: type list not found parsing union type at '('

philrz avatar Jan 22 '24 23:01 philrz

In the time since this issue was first opened, we've spotted some additional problems with the rendering of named types. The repro below is at Zui commit 67797fd and uses the following input data.zson:

{
    nest1: {
        foo: "bar"
    },
    nest2: {
        foo: "bar"
    } (=AnotherName),
    nest3: {
        foo: "bar"
    }
}

The attached video shows three problems related to the named type in this data:

  1. There's no leading = shown in the type decorator for AnotherName like we see in the ZSON rendering from the CLI tooling. As the ZSON spec describes, the = is necessary when it's defined as a new type but then can be dropped in later references.
  2. In the Columns picker, the nested field foo is not shown for the nested record that's a named type. This symptom was first reported to us by a community zync user.
  3. The named type is described in the Columns picker as an <alias>, but this terminology has been purged from Zed in favor of "named type". In any case, for the purposes of what's shown in the Column picker, I imagine labeling it <record> is probably still appropriate, though it may be worth polling the Zed dev team for input as well.

https://github.com/brimdata/zui/assets/5934157/abfb1d2b-62fa-42d5-8e5e-43ba49456319

philrz avatar Feb 08 '24 00:02 philrz