ast

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2022 License: BSD-3-Clause Imports: 6 Imported by: 1

Documentation

Overview

Package ast declares the types used to represent syntax trees for Zed queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnpackJSON

func UnpackJSON(buf []byte) (interface{}, error)

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.

func (*Agg) ExprAST

func (*Agg) ExprAST()

type ArrayExpr

type ArrayExpr struct {
	Kind  string       `json:"kind" unpack:""`
	Elems []VectorElem `json:"elems"`
}

func (*ArrayExpr) ExprAST

func (*ArrayExpr) ExprAST()

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.

func (*Call) ExprAST

func (*Call) ExprAST()

type Case

type Case struct {
	Expr Expr `json:"expr"`
	Op   Op   `json:"op"`
}

type Cast

type Cast struct {
	Kind string `json:"kind" unpack:""`
	Expr Expr   `json:"expr"`
	Type Expr   `json:"type"`
}

func (*Cast) ExprAST

func (*Cast) ExprAST()

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.

func (*Cut) OpAST added in v1.1.0

func (*Cut) OpAST()

type Def added in v1.0.0

type Def struct {
	Name string `json:"name"`
	Expr Expr   `json:"expr"`
}

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

type Drop struct {
	Kind string `json:"kind" unpack:""`
	Args []Expr `json:"args"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Drop) OpAST added in v1.1.0

func (*Drop) OpAST()

type EntryExpr

type EntryExpr struct {
	Key   Expr `json:"key"`
	Value Expr `json:"value"`
}

type Explode

type Explode struct {
	Kind string      `json:"kind" unpack:""`
	Args []Expr      `json:"args"`
	Type astzed.Type `json:"type"`
	As   Expr        `json:"as"`
}

func (*Explode) OpAST added in v1.1.0

func (*Explode) OpAST()

type Expr

type Expr interface {
	ExprAST()
}

type Field added in v1.0.0

type Field struct {
	Kind  string `json:"kind" unpack:""`
	Name  string `json:"name"`
	Value Expr   `json:"value"`
}

type File

type File struct {
	Kind   string  `json:"kind" unpack:""`
	Path   string  `json:"path"`
	Format string  `json:"format"`
	Layout *Layout `json:"layout"`
}

func (*File) Source

func (*File) Source()

type From

type From struct {
	Kind   string  `json:"kind" unpack:""`
	Trunks []Trunk `json:"trunks"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*From) OpAST added in v1.1.0

func (*From) OpAST()

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.

func (*Fuse) OpAST added in v1.1.0

func (*Fuse) OpAST()

type Glob added in v1.0.0

type Glob struct {
	Kind    string `json:"kind" unpack:""`
	Pattern string `json:"pattern"`
}

func (*Glob) ExprAST added in v1.0.0

func (*Glob) ExprAST()

func (*Glob) PatternAST added in v1.0.0

func (*Glob) PatternAST()

type Grep added in v1.0.0

type Grep struct {
	Kind    string  `json:"kind" unpack:""`
	Pattern Pattern `json:"pattern"`
	Expr    Expr    `json:"expr"`
}

func (*Grep) ExprAST added in v1.0.0

func (*Grep) ExprAST()

type HTTP

type HTTP struct {
	Kind   string  `json:"kind" unpack:""`
	URL    string  `json:"url"`
	Format string  `json:"format"`
	Layout *Layout `json:"layout"`
}

func (*HTTP) Source

func (*HTTP) Source()
type Head struct {
	Kind  string `json:"kind" unpack:""`
	Count int    `json:"count"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Head) OpAST added in v1.1.0

func (*Head) OpAST()

type ID

type ID struct {
	Kind string `json:"kind" unpack:""`
	Name string `json:"name"`
}

func (*ID) ExprAST

func (*ID) ExprAST()

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.

func (*Join) OpAST added in v1.1.0

func (*Join) OpAST()

type Layout

type Layout struct {
	Kind  string `json:"kind" unpack:""`
	Keys  []Expr `json:"keys"`
	Order string `json:"order"`
}

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.

func (*Let) OpAST added in v1.1.0

func (*Let) OpAST()

type MapExpr

type MapExpr struct {
	Kind    string      `json:"kind" unpack:""`
	Entries []EntryExpr `json:"entries"`
}

func (*MapExpr) ExprAST

func (*MapExpr) ExprAST()

type Merge added in v1.0.0

type Merge struct {
	Kind string `json:"kind" unpack:""`
	Expr Expr   `json:"expr"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Merge) OpAST added in v1.1.0

func (*Merge) OpAST()

type Op added in v1.1.0

type Op interface {
	OpAST()
}

Op is the interface implemented by all AST operator nodes.

func Copy

func Copy(in Op) Op

func UnpackJSONAsOp added in v1.1.0

func UnpackJSONAsOp(buf []byte) (Op, error)

UnpackJSONAsOp transforms a JSON representation of an operator into an Op.

func UnpackMapAsOp added in v1.1.0

func UnpackMapAsOp(m interface{}) (Op, error)

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

type OpExpr struct {
	Kind string `json:"kind" unpack:""`
	Expr Expr   `json:"expr"`
}

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.

func (*OpExpr) OpAST added in v1.1.0

func (*OpExpr) OpAST()

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.

func (*Over) OpAST added in v1.1.0

func (*Over) OpAST()

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"`
}

func (*OverExpr) ExprAST added in v1.1.0

func (*OverExpr) ExprAST()

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.

func (*Parallel) OpAST added in v1.1.0

func (*Parallel) OpAST()

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.

func (*Pass) OpAST added in v1.1.0

func (*Pass) OpAST()

func (*Pass) Source

func (*Pass) Source()

type Pattern added in v1.0.0

type Pattern interface {
	PatternAST()
}

type Pool

type Pool struct {
	Kind      string   `json:"kind" unpack:""`
	Spec      PoolSpec `json:"spec"`
	At        string   `json:"at"`
	Range     *Range   `json:"range"`
	ScanOrder string   `json:"scan_order"` // asc, desc, or unknown
}

func (*Pool) Source

func (*Pool) Source()

type PoolSpec

type PoolSpec struct {
	Pool   string `json:"pool"`
	Commit string `json:"commit"`
	Meta   string `json:"meta"`
}

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.

func (*Put) OpAST added in v1.1.0

func (*Put) OpAST()

type Range

type Range struct {
	Kind  string `json:"kind" unpack:""`
	Lower Expr   `json:"lower"`
	Upper Expr   `json:"upper"`
}

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

type Regexp struct {
	Kind    string `json:"kind" unpack:""`
	Pattern string `json:"pattern"`
}

func (*Regexp) ExprAST added in v1.0.0

func (*Regexp) ExprAST()

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.

func (*Rename) OpAST added in v1.1.0

func (*Rename) OpAST()

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.

func (*SQLExpr) ExprAST

func (*SQLExpr) ExprAST()

func (*SQLExpr) OpAST added in v1.1.0

func (*SQLExpr) OpAST()

type SQLFrom

type SQLFrom struct {
	Table Expr `json:"table"`
	Alias Expr `json:"alias"`
}

type SQLJoin

type SQLJoin struct {
	Table    Expr   `json:"table"`
	Style    string `json:"style"`
	LeftKey  Expr   `json:"left_key"`
	RightKey Expr   `json:"right_key"`
	Alias    Expr   `json:"alias"`
}

type SQLOrderBy

type SQLOrderBy struct {
	Kind  string      `json:"kind" unpack:""`
	Keys  []Expr      `json:"keys"`
	Order order.Which `json:"order"`
}
type Search struct {
	Kind string `json:"kind" unpack:""`
	Expr Expr   `json:"expr"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Search) OpAST added in v1.1.0

func (*Search) OpAST()

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"`
}

func (*SetExpr) ExprAST

func (*SetExpr) ExprAST()

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.

func (*Shape) OpAST added in v1.1.0

func (*Shape) OpAST()

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.

func (*Sort) OpAST added in v1.1.0

func (*Sort) OpAST()

type Source

type Source interface {
	Source()
}

type Spread added in v1.0.0

type Spread struct {
	Kind string `json:"kind" unpack:""`
	Expr Expr   `json:"expr"`
}

type String added in v1.0.0

type String struct {
	Kind string `json:"kind" unpack:""`
	Text string `json:"text"`
}

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.

func (*Summarize) OpAST added in v1.1.0

func (*Summarize) OpAST()

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.

func (*Switch) OpAST added in v1.1.0

func (*Switch) OpAST()

type Tail

type Tail struct {
	Kind  string `json:"kind" unpack:""`
	Count int    `json:"count"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Tail) OpAST added in v1.1.0

func (*Tail) OpAST()

type Term added in v1.0.0

type Term struct {
	Kind  string     `json:"kind" unpack:""`
	Text  string     `json:"text"`
	Value astzed.Any `json:"value"`
}

func (*Term) ExprAST added in v1.0.0

func (*Term) ExprAST()

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.

func (*Top) OpAST added in v1.1.0

func (*Top) OpAST()

type Trunk

type Trunk struct {
	Kind   string      `json:"kind" unpack:""`
	Source Source      `json:"source"`
	Seq    *Sequential `json:"seq"`
}

type UnaryExpr

type UnaryExpr struct {
	Kind    string `json:"kind" unpack:""`
	Op      string `json:"op"`
	Operand Expr   `json:"operand"`
}

func (*UnaryExpr) ExprAST

func (*UnaryExpr) ExprAST()

type Uniq

type Uniq struct {
	Kind  string `json:"kind" unpack:""`
	Cflag bool   `json:"cflag"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Uniq) OpAST added in v1.1.0

func (*Uniq) OpAST()

type VectorElem added in v1.2.0

type VectorElem interface {
	// contains filtered or unexported methods
}

type VectorValue added in v1.2.0

type VectorValue struct {
	Kind string `json:"kind" unpack:""`
	Expr Expr   `json:"expr"`
}

type Where added in v1.0.0

type Where struct {
	Kind string `json:"kind" unpack:""`
	Expr Expr   `json:"expr"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Where) OpAST added in v1.1.0

func (*Where) OpAST()

type Yield added in v1.0.0

type Yield struct {
	Kind  string `json:"kind" unpack:""`
	Exprs []Expr `json:"exprs"`
}

An Op is a node in the flowgraph that takes Zed values in, operates upon them, and produces Zed values as output.

func (*Yield) OpAST added in v1.1.0

func (*Yield) OpAST()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL