From f728ad3767b7ebf8839e25220d7a1a340188ce46 Mon Sep 17 00:00:00 2001 From: Matthew Nibecker Date: Thu, 25 Jul 2024 11:23:20 -0700 Subject: [PATCH] describe: Fix Scope channels (#5189) Fix is an issue with compile/describe where the channels inside of a Scope were not getting properly described. --- compiler/describe/analyze.go | 2 ++ compiler/optimizer/optimizer.go | 2 ++ service/ztests/query-describe.yaml | 13 ++++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/describe/analyze.go b/compiler/describe/analyze.go index 69c5f247ec..3ddf992df0 100644 --- a/compiler/describe/analyze.go +++ b/compiler/describe/analyze.go @@ -149,6 +149,8 @@ func describeAggs(seq dag.Seq, parents []field.List) []field.List { func describeOpAggs(op dag.Op, parents []field.List) []field.List { switch op := op.(type) { + case *dag.Scope: + return describeAggs(op.Body, parents) case *dag.Fork: var aggs []field.List for _, p := range op.Paths { diff --git a/compiler/optimizer/optimizer.go b/compiler/optimizer/optimizer.go index f398e94341..badb38ddb7 100644 --- a/compiler/optimizer/optimizer.go +++ b/compiler/optimizer/optimizer.go @@ -367,6 +367,8 @@ func (o *Optimizer) propagateSortKeyOp(op dag.Op, parents []order.SortKey) ([]or case *dag.PoolScan, *dag.Lister, *dag.SeqScan, *dag.DefaultScan: out, err := o.sortKeyOfSource(op) return []order.SortKey{out}, err + case *dag.Scope: + return o.propagateSortKey(op.Body, parents) default: out, err := o.analyzeSortKey(op, parent) return []order.SortKey{out}, err diff --git a/service/ztests/query-describe.yaml b/service/ztests/query-describe.yaml index 404be01d00..dcaecb9728 100644 --- a/service/ztests/query-describe.yaml +++ b/service/ztests/query-describe.yaml @@ -36,7 +36,7 @@ inputs: - name: scope.zed data: | type port = uint16 - from test1 + from test1 | fork (=> pass => yield "bar") outputs: - name: stdout @@ -181,6 +181,17 @@ outputs: "inferred": false }, "channels": [ + { + "aggregation_keys": null, + "sort": { + "order": "desc", + "keys": [ + [ + "ts" + ] + ] + } + }, { "aggregation_keys": null, "sort": null