zed icon indicating copy to clipboard operation
zed copied to clipboard

Debug operator taking a flowgraph rather than an expression

Open philrz opened this issue 1 year ago • 2 comments

When reacting to the debug operator in its current form, @mccanne found himself wishing it could take a flowgraph rather than expression to massage its output. I know this idea was kicked around at one point during its design, so this issue just serves a reminder for us to contemplate that in the future.

philrz avatar Sep 04 '24 22:09 philrz

Can we get an example of what this looks like?

mattnibs avatar Sep 06 '24 02:09 mattnibs

@mattnibs: I discussed with @mccanne and here's an example.

Let's start from this baseline:

$ echo '1 2 2 3' | zq -z -
1
2
2
3

He gave the example that he often finds himself wanting to see his data's by grouping as debug output, e.g., what's shown here:

$ echo '1 2 2 3' | zq -z 'by debug_info:=this' -
{debug_info:1}
{debug_info:2}
{debug_info:3}

It does seem like new syntax would be needed to demarcate the inline flowgraph, e.g.,

$ echo '1 2 2 3' | zq -z 'debug (by debug_info:=this)' -

It was also pointed out that by supporting flowgraphs like this the user could easily just invoke expressions via yield if that's all they need, whereas right now where only expressions are supported debug is limited to only working with single values at a time and hence no ability to do summaries like shown here.

philrz avatar Sep 09 '24 19:09 philrz