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 OpAssignment
- type OpExpr
- type Over
- type Parallel
- type Pass
- type Pattern
- type Pool
- type PoolSpec
- type Proc
- 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 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 Assignment ¶
type Assignment struct {
Kind string `json:"kind" unpack:""`
LHS Expr `json:"lhs"`
RHS Expr `json:"rhs"`
}
func NewAggAssignment ¶
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 proc, 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"`
}
A Cut proc represents a proc that removes fields from each input record where each removed field matches one of the named fields sending each such modified record to its output in the order received.
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 Explode ¶
type File ¶
type From ¶
A proc is a node in the flowgraph that takes records in, processes them, and produces records as output.
type Fuse ¶
type Fuse struct {
Kind string `json:"kind" unpack:""`
}
A Fuse proc represents a proc that turns a zng stream into a dataframe.
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 ¶
A Head proc represents a proc that forwards the indicated number of records then terminates.
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"`
}
A Join proc represents a proc that joins two zng streams.
type Layout ¶
type Let ¶ added in v1.0.0
type Let struct {
Kind string `json:"kind" unpack:""`
Locals []Def `json:"locals"`
Over *Over `json:"over"`
}
A proc is a node in the flowgraph that takes records in, processes them, and produces records as output.
type Merge ¶ added in v1.0.0
A proc is a node in the flowgraph that takes records in, processes them, and produces records as output.
type OpAssignment ¶
type OpAssignment struct {
Kind string `json:"kind" unpack:""`
Assignments []Assignment `json:"assignments"`
}
An OpAssignment proc is a list of assignments whose parent proc is unknown: It could be a Summarize or Put proc. This will be determined in the semantic phase.
func (*OpAssignment) ProcAST ¶
func (*OpAssignment) ProcAST()
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"`
As string `json:"as"`
Scope *Sequential `json:"scope"`
}
A proc is a node in the flowgraph that takes records in, processes them, and produces records as output.
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 proc 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"`
Procs []Proc `json:"procs"`
}
A Parallel proc represents a set of procs that each get a stream of records from their parent.
type Pass ¶
type Pass struct {
Kind string `json:"kind" unpack:""`
}
A Pass proc represents a passthrough proc that mirrors incoming Pull()s on its parent and returns the result.
type Pool ¶
type Proc ¶
type Proc interface {
ProcAST()
}
Proc is the interface implemented by all AST processor nodes.
func UnpackJSONAsProc ¶
UnpackJSONAsProc transforms a JSON representation of a proc into an ast.Proc.
func UnpackMapAsProc ¶
type Put ¶
type Put struct {
Kind string `json:"kind" unpack:""`
Args []Assignment `json:"args"`
}
A proc is a node in the flowgraph that takes records in, processes them, and produces records 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"`
}
A Rename proc represents a proc that renames fields.
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 a proc, 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 ¶
A proc is a node in the flowgraph that takes records in, processes them, and produces records as output.
type Sequential ¶
type Sequential struct {
Kind string `json:"kind" unpack:""`
Consts []Def `json:"consts"`
Procs []Proc `json:"procs"`
}
A Sequential proc represents a set of procs that receive a stream of records from their parent into the first proc and each subsequent proc processes the output records from the previous proc.
func (*Sequential) Prepend ¶
func (seq *Sequential) Prepend(front Proc)
func (*Sequential) ProcAST ¶
func (*Sequential) ProcAST()
type Shape ¶
type Shape struct {
Kind string `json:"kind" unpack:""`
}
A proc is a node in the flowgraph that takes records in, processes them, and produces records 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"`
}
A Sort proc represents a proc that sorts records.
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"`
}
A Summarize proc represents a proc that consumes all the records in its input, partitions the records into groups based on the values of the fields specified in the keys field (where the first key is the primary grouping key), and applies aggregators (if any) to each group. The InputSortDir field indicates that input is sorted (with direction indicated by the sign of the field) in the primary grouping key. In this case, the proc outputs the aggregation results from each key as they complete so that large inputs are processed and streamed efficiently. The Limit field specifies the number of different groups that can be aggregated over. When absent, the runtime defaults to an appropriate value. If PartialsOut is true, the proc will produce partial aggregation output result; likewise, if PartialsIn is true, the proc will expect partial results as input.
type Switch ¶
type Switch struct {
Kind string `json:"kind" unpack:""`
Expr Expr `json:"expr"`
Cases []Case `json:"cases"`
}
A Switch proc represents a set of procs that each get a stream of records from their parent.
type Tail ¶
A Tail proc represents a proc that reads all its records from its input transmits the final number of records indicated by the count.
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"`
}
A Top proc is similar to a Sort with a few key differences: - It only sorts in descending order. - It utilizes a MaxHeap, immediately discarding records that are not in the top N of the sort. - It has an option (Flush) to sort and emit on every batch.
type Trunk ¶
type Trunk struct {
Kind string `json:"kind" unpack:""`
Source Source `json:"source"`
Seq *Sequential `json:"seq"`
}
type UnaryExpr ¶
type Uniq ¶
A Uniq proc represents a proc that discards any record that matches the previous record transmitted. The Cflag causes the output records to contain a new field called count that contains the number of matched records in that set, similar to the unix shell command uniq.