Skip to content

Commit

Permalink
query describe endpoint: Fix scopes (#5152)
Browse files Browse the repository at this point in the history
This commit fixes an issue with the query describe endpoint where a
query having a scope would cause the endpoint to return an error.
  • Loading branch information
mattnibs committed Jun 28, 2024
1 parent dfdf3e6 commit ab603fa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/describe/analyze.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ func Analyze(ctx context.Context, query string, src *data.Source, head *lakepars

func describeSources(ctx context.Context, lk *lake.Root, o dag.Op, inferred bool) ([]Source, error) {
switch o := o.(type) {
case *dag.Scope:
return describeSources(ctx, lk, o.Body[0], inferred)
case *dag.Fork:
var s []Source
for _, p := range o.Paths {
Expand Down
21 changes: 20 additions & 1 deletion service/ztests/query-describe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ script: |
source service.sh
zed create -q test1
zed create -q test2
for file in multifrom.zed agg.zed agg-no-keys.zed two-channels.zed agg-sort.zed; do
for file in multifrom.zed agg.zed agg-no-keys.zed two-channels.zed agg-sort.zed scope.zed; do
echo // === $file ===
query="$(cat $file | jq -Rsa .)"
curl -H "Accept: application/json" -d "{\"query\":$query,\"head\":{\"pool\":\"test1\"}}" $ZED_LAKE/query/describe |
Expand Down Expand Up @@ -33,6 +33,10 @@ inputs:
- name: agg-sort.zed
data: |
sum(this) by foo | sort x
- name: scope.zed
data: |
type port = uint16
from test1
outputs:
- name: stdout
Expand Down Expand Up @@ -168,3 +172,18 @@ outputs:
}
]
}
// === scope.zed ===
{
"sources": {
"kind": "Pool",
"name": "test1",
"id": "XXX",
"inferred": false
},
"channels": [
{
"aggregation_keys": null,
"sort": null
}
]
}

0 comments on commit ab603fa

Please sign in to comment.