diff --git a/compiler/ast/dag/op.go b/compiler/ast/dag/op.go index c6b4624657..491789bfac 100644 --- a/compiler/ast/dag/op.go +++ b/compiler/ast/dag/op.go @@ -41,7 +41,7 @@ type ( Kind string `json:"kind" unpack:""` Args []Expr `json:"args"` Type string `json:"type"` - As Expr `json:"as"` + As string `json:"as"` } Filter struct { Kind string `json:"kind" unpack:""` diff --git a/compiler/kernel/op.go b/compiler/kernel/op.go index e536607bb6..8d8aa7467d 100644 --- a/compiler/kernel/op.go +++ b/compiler/kernel/op.go @@ -224,14 +224,7 @@ func (b *Builder) compileLeaf(o dag.Op, parent zbuf.Puller) (zbuf.Puller, error) if err != nil { return nil, err } - as, err := compileLval(v.As) - if err != nil { - return nil, err - } - if len(as) != 1 { - return nil, errors.New("explode field must be a top-level field") - } - return explode.New(b.octx.Zctx, parent, args, typ, as.Leaf()) + return explode.New(b.octx.Zctx, parent, args, typ, v.As) case *dag.Over: return b.compileOver(parent, v) case *dag.Yield: diff --git a/compiler/semantic/op.go b/compiler/semantic/op.go index 4b2bb59276..621fbb1787 100644 --- a/compiler/semantic/op.go +++ b/compiler/semantic/op.go @@ -692,17 +692,21 @@ func (a *analyzer) semOp(o ast.Op, seq dag.Seq) (dag.Seq, error) { if err != nil { return nil, err } - var as dag.Expr + var as string if o.As == nil { - as = &dag.This{ - Kind: "This", - Path: field.Path{"value"}, - } + as = "value" } else { - as, err = a.semExpr(o.As) + e, err := a.semExpr(o.As) if err != nil { return nil, err } + this, ok := e.(*dag.This) + if !ok { + return nil, errors.New("explode: as clause must be a field reference") + } else if len(this.Path) != 1 { + return nil, errors.New("explode: field must be a top-level field") + } + as = this.Path[0] } return append(seq, &dag.Explode{ Kind: "Explode",