Documentation ¶
Overview ¶
Package ast declares the types used to represent syntax trees for Zed queries.
Index ¶
- func UnpackJSON(buf []byte) (interface{}, error)
- type Agg
- type ArrayExpr
- type Assignment
- type BinaryExpr
- type Call
- type Case
- type Cast
- type Conditional
- type Cut
- type Def
- type Drop
- type EntryExpr
- type Explode
- type Expr
- type Field
- type File
- type From
- type Fuse
- type Glob
- type Grep
- type HTTP
- type Head
- type ID
- type Join
- type Layout
- type Let
- type MapExpr
- type Merge
- type Op
- type OpAssignment
- type OpExpr
- type Over
- type OverExpr
- type Parallel
- type Pass
- type Pattern
- type Pool
- type PoolSpec
- type Put
- type Range
- type RecordElem
- type RecordExpr
- type Regexp
- type Rename
- type SQLExpr
- type SQLFrom
- type SQLJoin
- type SQLOrderBy
- type Search
- type Sequential
- type SetExpr
- type Shape
- type Sort
- type Source
- type Spread
- type String
- type Summarize
- type Switch
- type Tail
- type Term
- type Top
- type Trunk
- type UnaryExpr
- type Uniq
- type VectorElem
- type VectorValue
- type Where
- type Yield
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnpackJSON ¶
Types ¶
type Agg ¶
type Agg struct { Kind string `json:"kind" unpack:""` Name string `json:"name"` Expr Expr `json:"expr"` Where Expr `json:"where"` }
An Agg is an AST node that represents a aggregate function. The Name field indicates the aggregation method while the Expr field indicates an expression applied to the incoming records that is operated upon by them aggregate function. If Expr isn't present, then the aggregator doesn't act upon a function of the record, e.g., count() counts up records without looking into them.
type ArrayExpr ¶
type ArrayExpr struct { Kind string `json:"kind" unpack:""` Elems []VectorElem `json:"elems"` }
type Assignment ¶
type Assignment struct { Kind string `json:"kind" unpack:""` LHS Expr `json:"lhs"` RHS Expr `json:"rhs"` }
func (*Assignment) ExprAST ¶
func (*Assignment) ExprAST()
type BinaryExpr ¶
type BinaryExpr struct { Kind string `json:"kind" unpack:""` Op string `json:"op"` LHS Expr `json:"lhs"` RHS Expr `json:"rhs"` }
A BinaryExpr is any expression of the form "lhs kind rhs" including arithmetic (+, -, *, /), logical operators (and, or), comparisons (=, !=, <, <=, >, >=), index operatons (on arrays, sets, and records) with kind "[" and a dot expression (".") (on records).
func (*BinaryExpr) ExprAST ¶
func (*BinaryExpr) ExprAST()
type Call ¶
type Call struct { Kind string `json:"kind" unpack:""` Name string `json:"name"` Args []Expr `json:"args"` Where Expr `json:"where"` }
A Call represents different things dependending on its context. As a operator, it is either a group-by with no group-by keys and no duration, or a filter with a function that is boolean valued. This is determined by the compiler rather than the syntax tree based on the specific functions and aggregators that are defined at compile time. In expression context, a function call has the standard semantics where it takes one or more arguments and returns a result.
type Cast ¶
type Conditional ¶
type Conditional struct { Kind string `json:"kind" unpack:""` Cond Expr `json:"cond"` Then Expr `json:"then"` Else Expr `json:"else"` }
func (*Conditional) ExprAST ¶
func (*Conditional) ExprAST()
type Cut ¶
type Cut struct { Kind string `json:"kind" unpack:""` Args []Assignment `json:"args"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Def ¶ added in v1.0.0
Def is like Assignment but the LHS is an identifier that may be later referenced. This is used for const blocks in Sequential and var blocks in a let scope.
type Drop ¶
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Explode ¶
type File ¶
type From ¶
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Fuse ¶
type Fuse struct {
Kind string `json:"kind" unpack:""`
}
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Glob ¶ added in v1.0.0
func (*Glob) PatternAST ¶ added in v1.0.0
func (*Glob) PatternAST()
type Grep ¶ added in v1.0.0
type HTTP ¶
type Head ¶
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Join ¶
type Join struct { Kind string `json:"kind" unpack:""` Style string `json:"style"` LeftKey Expr `json:"left_key"` RightKey Expr `json:"right_key"` Args []Assignment `json:"args"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Let ¶ added in v1.0.0
type Let struct { Kind string `json:"kind" unpack:""` Locals []Def `json:"locals"` Over *Over `json:"over"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Merge ¶ added in v1.0.0
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Op ¶ added in v1.1.0
type Op interface {
OpAST()
}
Op is the interface implemented by all AST operator nodes.
func UnpackJSONAsOp ¶ added in v1.1.0
UnpackJSONAsOp transforms a JSON representation of an operator into an Op.
func UnpackMapAsOp ¶ added in v1.1.0
type OpAssignment ¶
type OpAssignment struct { Kind string `json:"kind" unpack:""` Assignments []Assignment `json:"assignments"` }
An OpAssignment is a list of assignments whose parent operator is unknown: It could be a Summarize or Put operator. This will be determined in the semantic phase.
func (*OpAssignment) OpAST ¶ added in v1.1.0
func (*OpAssignment) OpAST()
type OpExpr ¶ added in v1.0.0
An OpExpr operator is an expression that appears as an operator and requires semantic analysis to determine if it is a filter, a yield, or an aggregation.
type Over ¶ added in v1.0.0
type Over struct { Kind string `json:"kind" unpack:""` Exprs []Expr `json:"exprs"` Scope *Sequential `json:"scope"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type OverExpr ¶ added in v1.1.0
type OverExpr struct { Kind string `json:"kind" unpack:""` Locals []Def `json:"locals"` Exprs []Expr `json:"exprs"` Scope *Sequential `json:"scope"` }
type Parallel ¶
type Parallel struct { Kind string `json:"kind" unpack:""` // If non-zero, MergeBy contains the field name on // which the branches of this parallel operator should be // merged in the order indicated by MergeReverse. // XXX merge_by should be a list of expressions MergeBy field.Path `json:"merge_by,omitempty"` MergeReverse bool `json:"merge_reverse,omitempty"` Ops []Op `json:"ops"` }
A Parallel operator represents a set of operators that each get a stream of Zed values from their parent.
type Pass ¶
type Pass struct {
Kind string `json:"kind" unpack:""`
}
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Pool ¶
type Put ¶
type Put struct { Kind string `json:"kind" unpack:""` Args []Assignment `json:"args"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type RecordElem ¶ added in v1.0.0
type RecordElem interface {
// contains filtered or unexported methods
}
type RecordExpr ¶
type RecordExpr struct { Kind string `json:"kind" unpack:""` Elems []RecordElem `json:"elems"` }
func (*RecordExpr) ExprAST ¶
func (*RecordExpr) ExprAST()
type Regexp ¶ added in v1.0.0
func (*Regexp) PatternAST ¶ added in v1.0.0
func (*Regexp) PatternAST()
type Rename ¶
type Rename struct { Kind string `json:"kind" unpack:""` Args []Assignment `json:"args"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type SQLExpr ¶
type SQLExpr struct { Kind string `json:"kind" unpack:""` Select []Assignment `json:"select"` From *SQLFrom `json:"from"` Joins []SQLJoin `json:"joins"` Where Expr `json:"where"` GroupBy []Expr `json:"group_by"` Having Expr `json:"having"` OrderBy *SQLOrderBy `json:"order_by"` Limit int `json:"limit"` }
A SQLExpr can be an operator, an expression inside of a SQL FROM clause, or an expression used as a Zed value generator. Currenly, the "select" keyword collides with the select() generator function (it can be parsed unambiguosly because of the parens but this is not user friendly so we need a new name for select()... see issue #2133). TBD: from alias, "in" over tuples, WITH sub-queries, multi-table FROM implying a JOIN, aliases for tables in FROM and JOIN.
type SQLOrderBy ¶
type Search ¶
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Sequential ¶
type Sequential struct { Kind string `json:"kind" unpack:""` Consts []Def `json:"consts"` Ops []Op `json:"ops"` }
A Sequential operator represents a set of operators that receive a stream of Zed values from their parent into the first operator and each subsequent operator processes the output records from the previous operator.
func (*Sequential) OpAST ¶ added in v1.1.0
func (*Sequential) OpAST()
func (*Sequential) Prepend ¶
func (seq *Sequential) Prepend(front Op)
type SetExpr ¶
type SetExpr struct { Kind string `json:"kind" unpack:""` Elems []VectorElem `json:"elems"` }
type Shape ¶
type Shape struct {
Kind string `json:"kind" unpack:""`
}
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Sort ¶
type Sort struct { Kind string `json:"kind" unpack:""` Args []Expr `json:"args"` Order order.Which `json:"order"` NullsFirst bool `json:"nullsfirst"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type String ¶ added in v1.0.0
func (*String) PatternAST ¶ added in v1.0.0
func (*String) PatternAST()
type Summarize ¶
type Summarize struct { Kind string `json:"kind" unpack:""` Limit int `json:"limit"` Keys []Assignment `json:"keys"` Aggs []Assignment `json:"aggs"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Switch ¶
type Switch struct { Kind string `json:"kind" unpack:""` Expr Expr `json:"expr"` Cases []Case `json:"cases"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Tail ¶
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Term ¶ added in v1.0.0
type Top ¶
type Top struct { Kind string `json:"kind" unpack:""` Limit int `json:"limit"` Args []Expr `json:"args"` Flush bool `json:"flush"` }
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type Trunk ¶
type Trunk struct { Kind string `json:"kind" unpack:""` Source Source `json:"source"` Seq *Sequential `json:"seq"` }
type UnaryExpr ¶
type Uniq ¶
An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.
type VectorElem ¶ added in v1.2.0
type VectorElem interface {
// contains filtered or unexported methods
}