expr

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 19 Imported by: 162

Documentation

Overview

Expression structures, ie the `a = b` type expression syntax including parser, node types, boolean logic check, functions.

Package expr is a generated protocol buffer package.

It is generated from these files:
	node.proto

It has these top-level messages:
	ExprPb
	NodePb
	BinaryNodePb
	BooleanNodePb
	IncludeNodePb
	UnaryNodePb
	FuncNodePb
	TriNodePb
	ArrayNodePb
	StringNodePb
	IdentityNodePb
	NumberNodePb
	ValueNodePb
	NullNodePb

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotSupported indicates an error of a piece of expression syntax not
	// being supported.
	ErrNotSupported = fmt.Errorf("Not supported")
	// ErrNotImplemented an error of expression/statement syntax not being supported
	ErrNotImplemented = fmt.Errorf("Not implemented")
	// ErrUnknownCommand Unknown Command
	ErrUnknownCommand = fmt.Errorf("Unknown Command")
	// ErrInternalError Internal Error
	ErrInternalError = fmt.Errorf("Internal Error")

	// ErrNoIncluder is message saying a FilterQL included reference
	// to an include when no Includer was available to resolve
	ErrNoIncluder = fmt.Errorf("No Includer is available")
	// ErrIncludeNotFound Include Not Found
	ErrIncludeNotFound = fmt.Errorf("Include Not Found")
)
View Source
var (
	ErrInvalidLengthNode = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowNode   = fmt.Errorf("proto: integer overflow")
)

We have a default Dialect, which is the "Language" or rule-set of ql

View Source
var (
	// If we hit max depth
	ErrMaxDepth = fmt.Errorf("Recursive Evaluation Error")
)
View Source
var (
	Trace bool
)

Functions

func EmptyEvalFunc

func EmptyEvalFunc(ctx EvalContext, args []value.Value) (value.Value, bool)

EmptyEvalFunc a no-op evaluation function for use in

func FilterSpecialIdentities

func FilterSpecialIdentities(l []string) []string

FilterSpecialIdentities given a list of identities, filter out special identities such as "null", "*", "match_all"

func FindAllIdentityField

func FindAllIdentityField(node Node) []string

FindAllIdentityField Recursively descend down a node looking for all Identity Fields

min(year)                 == {year}
eq(min(user.name), max(month)) == {user.name, month}

func FindAllLeftIdentityFields

func FindAllLeftIdentityFields(node Node) []string

FindAllLeftIdentityFields Recursively descend down a node looking for all LEFT Identity Fields

min(year)                 == {year}
eq(min(user.name), max(month)) == {user, month}

func FindFirstIdentity

func FindFirstIdentity(node Node) string

FindFirstIdentity Recursively descend down a node looking for first Identity Field

min(year)                 == year
eq(min(item), max(month)) == item
eq(min(user.last_name), max(month)) == user.last_name

func FindIdentityName

func FindIdentityName(depth int, node Node, prefix string) string

FindIdentityName Recursively walk a node looking for first Identity Field and combine with outermost expression to create an alias

min(year)                 => "min_year"
eq(min(year), max(month)) =>  "eq_year
EXISTS url                =>  "exists_url"

func FindIncludes

func FindIncludes(node Node) []string

FindIncludes recursively descend down a node looking for all Include identities

func FuncAdd

func FuncAdd(name string, fn CustomFunc)

FuncAdd Global add Functions to the VM func registry occurs here.

func IdentityMaybeEscapeBuf

func IdentityMaybeEscapeBuf(buf *bytes.Buffer, quote byte, ident string)

IdentityMaybeEscape Quote an identity/literal if need be (has illegal characters or spaces)

func IdentityMaybeQuote

func IdentityMaybeQuote(quote byte, ident string) string

IdentityMaybeQuote

func IdentityMaybeQuoteStrict

func IdentityMaybeQuoteStrict(quote byte, ident string) string

IdentityMaybeQuoteStrict Quote an identity if need be (has illegal characters or spaces) First character MUST be alpha (not numeric or any other character)

func IdentityMaybeQuoteStrictBuf

func IdentityMaybeQuoteStrictBuf(buf *bytes.Buffer, quote byte, ident string)

IdentityMaybeQuoteStrict Quote an identity if need be (has illegal characters or spaces)

First character MUST be alpha (not numeric or any other character)

func IdentityTrim

func IdentityTrim(ident string) string

IdentityTrim trims the leading/trailing identity quote marks ` or []

func IsValidIdentity

func IsValidIdentity(identity string) bool

IsValidIdentity test the given string to determine if any characters are not valid and therefore must be quoted

func LeftRight

func LeftRight(val string) (string, string, bool)

LeftRight Return left, right values if is of form `table.column` or `schema`.`table` also return true/false for if it even has left/right

func LiteralQuoteEscape

func LiteralQuoteEscape(quote rune, literal string) string

LiteralQuoteEscape escape string that may need characters escaped

LiteralQuoteEscape("'","item's") => 'item''s'
LiteralQuoteEscape(`"`,"item's") => "item's"
LiteralQuoteEscape(`"`,`item"s`) => "item""s"

func LiteralQuoteEscapeBuf

func LiteralQuoteEscapeBuf(buf *bytes.Buffer, quote rune, literal string)

LiteralQuoteEscapeBuf escape string that may need characters escaped

LiteralQuoteEscapeBuf("'","item's") => 'item''s'
LiteralQuoteEscapeBuf(`"`,"item's") => "item's"
LiteralQuoteEscapeBuf(`"`,`item"s`) => "item""s"

func NodesEqual

func NodesEqual(n1, n2 Node) bool

func StringEscape

func StringEscape(quote rune, literal string) string

StringEscape escape string that may need characters escaped

StringEscape("'","item's") => "item''s"

func StringUnEscape

func StringUnEscape(quote rune, val string) (string, bool)

StringUnEscape remove escaping on string that may need characters escaped

StringUnEscape(`"`,`item"s`) => "item""s", true

func ValueArray

func ValueArray(depth int, pg TokenPager) (value.Value, error)

ValueArray

IN ("a","b","c")
["a","b","c"]

func ValueTypeFromNode

func ValueTypeFromNode(n Node) value.ValueType

ValueTypeFromNode Infer Value type from Node

Types

type AggFunc

type AggFunc interface {
	IsAgg() bool
}

AggFunc allows custom functions to specify if they provide aggregation

type ArrayNode

type ArrayNode struct {
	Args []Node
	// contains filtered or unexported fields
}

ArrayNode for holding multiple similar elements

arg0 IN (arg1,arg2.....)
5 in (1,2,3,4)

func NewArrayNode

func NewArrayNode() *ArrayNode

NewArrayNode Create an array of Nodes which is a valid node type for boolean IN operator

func NewArrayNodeArgs

func NewArrayNodeArgs(args []Node) *ArrayNode

func (*ArrayNode) Append

func (m *ArrayNode) Append(n Node)

func (*ArrayNode) ChildrenArgs

func (m *ArrayNode) ChildrenArgs() []Node

func (*ArrayNode) Equal

func (m *ArrayNode) Equal(n Node) bool

func (*ArrayNode) Expr

func (m *ArrayNode) Expr() *Expr

func (*ArrayNode) FromExpr

func (m *ArrayNode) FromExpr(e *Expr) error

func (*ArrayNode) FromPB

func (m *ArrayNode) FromPB(n *NodePb) Node

func (*ArrayNode) NodePb

func (m *ArrayNode) NodePb() *NodePb

func (*ArrayNode) NodeType

func (m *ArrayNode) NodeType() string

func (*ArrayNode) String

func (m *ArrayNode) String() string

func (*ArrayNode) Validate

func (m *ArrayNode) Validate() error

func (*ArrayNode) WriteDialect

func (m *ArrayNode) WriteDialect(w DialectWriter)

type ArrayNodePb

type ArrayNodePb struct {
	Wrap             *int32   `protobuf:"varint,1,req,name=wrap" json:"wrap,omitempty"`
	Args             []NodePb `protobuf:"bytes,3,rep,name=args" json:"args"`
	XXX_unrecognized []byte   `json:"-"`
}

Array Node

func (*ArrayNodePb) Descriptor

func (*ArrayNodePb) Descriptor() ([]byte, []int)

func (*ArrayNodePb) Marshal

func (m *ArrayNodePb) Marshal() (data []byte, err error)

func (*ArrayNodePb) MarshalTo

func (m *ArrayNodePb) MarshalTo(data []byte) (int, error)

func (*ArrayNodePb) ProtoMessage

func (*ArrayNodePb) ProtoMessage()

func (*ArrayNodePb) Reset

func (m *ArrayNodePb) Reset()

func (*ArrayNodePb) Size

func (m *ArrayNodePb) Size() (n int)

func (*ArrayNodePb) String

func (m *ArrayNodePb) String() string

func (*ArrayNodePb) Unmarshal

func (m *ArrayNodePb) Unmarshal(data []byte) error

type BinaryNode

type BinaryNode struct {
	Paren    bool
	Args     []Node
	Operator lex.Token
	// contains filtered or unexported fields
}

BinaryNode is x op y, two nodes (left, right) and an operator operators can be a variety of:

+, -, *, %, /, LIKE, CONTAINS, INTERSECTS

Also, parenthesis may wrap these

func NewBinaryNode

func NewBinaryNode(operator lex.Token, lhArg, rhArg Node) *BinaryNode

Create a Binary node

 @operator = * + - %/ / && || = ==
 @operator =  and, or, "is not"
@lhArg, rhArg the left, right side of binary

func (*BinaryNode) ChildrenArgs

func (m *BinaryNode) ChildrenArgs() []Node

func (*BinaryNode) Equal

func (m *BinaryNode) Equal(n Node) bool

func (*BinaryNode) Expr

func (m *BinaryNode) Expr() *Expr

func (*BinaryNode) FromExpr

func (m *BinaryNode) FromExpr(e *Expr) error

func (*BinaryNode) FromPB

func (m *BinaryNode) FromPB(n *NodePb) Node

func (*BinaryNode) NodePb

func (m *BinaryNode) NodePb() *NodePb

func (*BinaryNode) NodeType

func (m *BinaryNode) NodeType() string

func (*BinaryNode) String

func (m *BinaryNode) String() string

func (*BinaryNode) Validate

func (m *BinaryNode) Validate() error

Negation I wanted to do negation on Binaries, but ended up not doing for now

ie, rewrite NOT (X == "y") => X != "y"

The general problem we ran into is that we lose some fidelity in collapsing AST that is necessary for other evaluation run-times.

logically `NOT (X > y)` is NOT THE SAME AS `(X <= y) due to lack of existence of X

func (m *BinaryNode) ReverseNegation() bool {
	switch m.Operator.T {
	case lex.TokenEqualEqual:
		m.Operator.T = lex.TokenNE
		m.Operator.V = m.Operator.T.String()
	case lex.TokenNE:
		m.Operator.T = lex.TokenEqualEqual
		m.Operator.V = m.Operator.T.String()
	case lex.TokenLT:
		m.Operator.T = lex.TokenGE
		m.Operator.V = m.Operator.T.String()
	case lex.TokenLE:
		m.Operator.T = lex.TokenGT
		m.Operator.V = m.Operator.T.String()
	case lex.TokenGT:
		m.Operator.T = lex.TokenLE
		m.Operator.V = m.Operator.T.String()
	case lex.TokenGE:
		m.Operator.T = lex.TokenLT
		m.Operator.V = m.Operator.T.String()
	default:
		//u.Warnf("What, what is this?   %s", m)
		m.negated = !m.negated
		return true
	}
	return true
}

func (m *BinaryNode) Collapse() Node { return m } func (m *BinaryNode) Negated() bool { return m.negated }

func (m *BinaryNode) StringNegate() string {
	w := NewDefaultWriter()
	m.WriteNegate(w)
	return w.String()
}
func (m *BinaryNode) WriteNegate(w DialectWriter) {
	switch m.Operator.T {
	case lex.TokenIN, lex.TokenIntersects, lex.TokenLike, lex.TokenContains:
		m.writeToString(w, "NOT ")
	default:
		m.writeToString(w, "")
	}
}

func (*BinaryNode) WriteDialect

func (m *BinaryNode) WriteDialect(w DialectWriter)

type BinaryNodePb

type BinaryNodePb struct {
	Op               int32    `protobuf:"varint,1,req,name=op" json:"op"`
	Paren            bool     `protobuf:"varint,2,opt,name=paren" json:"paren"`
	Args             []NodePb `protobuf:"bytes,3,rep,name=args" json:"args"`
	XXX_unrecognized []byte   `json:"-"`
}

Binary Node, two child args

func (*BinaryNodePb) Descriptor

func (*BinaryNodePb) Descriptor() ([]byte, []int)

func (*BinaryNodePb) Marshal

func (m *BinaryNodePb) Marshal() (data []byte, err error)

func (*BinaryNodePb) MarshalTo

func (m *BinaryNodePb) MarshalTo(data []byte) (int, error)

func (*BinaryNodePb) ProtoMessage

func (*BinaryNodePb) ProtoMessage()

func (*BinaryNodePb) Reset

func (m *BinaryNodePb) Reset()

func (*BinaryNodePb) Size

func (m *BinaryNodePb) Size() (n int)

func (*BinaryNodePb) String

func (m *BinaryNodePb) String() string

func (*BinaryNodePb) Unmarshal

func (m *BinaryNodePb) Unmarshal(data []byte) error

type BooleanNode

type BooleanNode struct {
	Args     []Node
	Operator lex.Token
	// contains filtered or unexported fields
}

BooleanNode is n nodes and an operator operators can be only AND/OR

func NewBooleanNode

func NewBooleanNode(operator lex.Token, args ...Node) *BooleanNode

NewBooleanNode Create a boolean node

 @operator = AND, OR
@args = nodes

func (*BooleanNode) ChildrenArgs

func (m *BooleanNode) ChildrenArgs() []Node

func (*BooleanNode) Collapse

func (m *BooleanNode) Collapse() Node

func (*BooleanNode) Equal

func (m *BooleanNode) Equal(n Node) bool

func (*BooleanNode) Expr

func (m *BooleanNode) Expr() *Expr

func (*BooleanNode) FromExpr

func (m *BooleanNode) FromExpr(e *Expr) error

func (*BooleanNode) FromPB

func (m *BooleanNode) FromPB(n *NodePb) Node

func (*BooleanNode) Negated

func (m *BooleanNode) Negated() bool

func (*BooleanNode) NodePb

func (m *BooleanNode) NodePb() *NodePb

func (*BooleanNode) NodeType

func (m *BooleanNode) NodeType() string

func (*BooleanNode) ReverseNegation

func (m *BooleanNode) ReverseNegation() bool

func (*BooleanNode) String

func (m *BooleanNode) String() string

func (*BooleanNode) StringNegate

func (m *BooleanNode) StringNegate() string

func (*BooleanNode) Validate

func (m *BooleanNode) Validate() error

func (*BooleanNode) WriteDialect

func (m *BooleanNode) WriteDialect(w DialectWriter)

func (*BooleanNode) WriteNegate

func (m *BooleanNode) WriteNegate(w DialectWriter)

type BooleanNodePb

type BooleanNodePb struct {
	Op               int32    `protobuf:"varint,1,req,name=op" json:"op"`
	Args             []NodePb `protobuf:"bytes,2,rep,name=args" json:"args"`
	XXX_unrecognized []byte   `json:"-"`
}

Boolean Node, n child args

func (*BooleanNodePb) Descriptor

func (*BooleanNodePb) Descriptor() ([]byte, []int)

func (*BooleanNodePb) Marshal

func (m *BooleanNodePb) Marshal() (data []byte, err error)

func (*BooleanNodePb) MarshalTo

func (m *BooleanNodePb) MarshalTo(data []byte) (int, error)

func (*BooleanNodePb) ProtoMessage

func (*BooleanNodePb) ProtoMessage()

func (*BooleanNodePb) Reset

func (m *BooleanNodePb) Reset()

func (*BooleanNodePb) Size

func (m *BooleanNodePb) Size() (n int)

func (*BooleanNodePb) String

func (m *BooleanNodePb) String() string

func (*BooleanNodePb) Unmarshal

func (m *BooleanNodePb) Unmarshal(data []byte) error

type ContextReadWriter

type ContextReadWriter interface {
	ContextReader
	ContextWriter
}

ContextReadWriter represents a Context which can be Read & Written.

type ContextReader

type ContextReader interface {
	Get(key string) (value.Value, bool)
	Row() map[string]value.Value
	Ts() time.Time
}

ContextReader is a key-value interface to read the context of message/row using a Get("key") interface. Used by vm to evaluate messages

type ContextWriter

type ContextWriter interface {
	Put(col SchemaInfo, readCtx ContextReader, v value.Value) error
	Delete(row map[string]value.Value) error
}

ContextWriter For evaluation storage vm writes results to this after evaluation

type CustomFunc

type CustomFunc interface {
	// Type Define the Return Type of this function, or use value.Value for unknown.
	Type() value.ValueType
	// Validate is parse time syntax and type evaluation.  Also returns the evaluation
	// function.
	Validate(n *FuncNode) (EvaluatorFunc, error)
}

CustomFunc allows custom functions to be added for run-time evaluation

type DialectWriter

type DialectWriter interface {
	io.Writer
	Len() int
	WriteLiteral(string)
	WriteIdentity(string)
	WriteLeftRightIdentity(string, string)
	WriteIdentityQuote(string, byte)
	WriteNumber(string)
	WriteNull()
	WriteValue(v value.Value)
	String() string
}

DialectWriter Defines interface to allow different dialects to have different escape characters. IE, given an AST structure allow the writer to control the string output. Allows translation between different dialects (different escapes) as well as allows normalization indentation, tabs, spacing, etc. - postgres: literal-escape = ' identity = " - mysql: literal-escape = " identity = ` - cql: literal-escape = ' identity = ` - bigquery: literal-escape = " identity = []

func NewDefaultNoNamspaceWriter

func NewDefaultNoNamspaceWriter() DialectWriter

NewDefaultNoNamspaceWriter uses mysql escaping rules literals=" identity=` Strip namespaces so that 'users.first_name` becomes `first_name` (strip users.)

func NewDefaultWriter

func NewDefaultWriter() DialectWriter

NewDefaultWriter uses mysql escaping rules literals=" identity=`

func NewDialectWriter

func NewDialectWriter(l, i byte) DialectWriter

NewDialectWriter creates a writer that is custom literal and identity escape characters

func NewFingerPrintWriter

func NewFingerPrintWriter(replace string, w DialectWriter) DialectWriter

func NewFingerPrinter

func NewFingerPrinter() DialectWriter

func NewJSONDialectWriter

func NewJSONDialectWriter() DialectWriter

NewJSONDialectWriter escape literal " with \"

func NewKeywordDialect

func NewKeywordDialect(kw []string) DialectWriter

type EvalContext

type EvalContext interface {
	ContextReader
}

EvalContext used to contain info for usage/lookup at runtime evaluation

type EvalIncludeContext

type EvalIncludeContext interface {
	ContextReader
	Includer
}

EvalIncludeContext context, used to contain info for usage/lookup at runtime evaluation

type EvaluatorFunc

type EvaluatorFunc func(ctx EvalContext, args []value.Value) (value.Value, bool)

EvaluatorFunc defines the evaluator func which may be stateful (or not) for evaluating custom functions

type Expr

type Expr struct {
	// The `Op` (aka token), and Args expressions are non
	// nil if it is an expression
	Op   string  `json:"op,omitempty"`
	Args []*Expr `json:"args,omitempty"`

	// If op is 0, and args nil then exactly one of these should be set
	Identity string `json:"ident,omitempty"`
	Value    string `json:"val,omitempty"`
}

Expr represents single part of an Expression, it is a generic AST structure that can be built in tree structure and JSON serialized to represent full AST as json.

func ExprsFromNodes

func ExprsFromNodes(nodes []Node) []*Expr

type ExprPb

type ExprPb struct {
	Op               *int32    `protobuf:"varint,1,opt,name=op" json:"op,omitempty"`
	Args             []*ExprPb `protobuf:"bytes,2,rep,name=args" json:"args,omitempty"`
	Ident            *string   `protobuf:"bytes,4,opt,name=ident" json:"ident,omitempty"`
	Val              *string   `protobuf:"bytes,5,opt,name=val" json:"val,omitempty"`
	Ival             *int64    `protobuf:"varint,6,opt,name=ival" json:"ival,omitempty"`
	Bval             *bool     `protobuf:"varint,7,opt,name=bval" json:"bval,omitempty"`
	Fval             *float64  `protobuf:"fixed64,8,opt,name=fval" json:"fval,omitempty"`
	XXX_unrecognized []byte    `json:"-"`
}

The generic Expr

func (*ExprPb) Descriptor

func (*ExprPb) Descriptor() ([]byte, []int)

func (*ExprPb) Marshal

func (m *ExprPb) Marshal() (data []byte, err error)

func (*ExprPb) MarshalTo

func (m *ExprPb) MarshalTo(data []byte) (int, error)

func (*ExprPb) ProtoMessage

func (*ExprPb) ProtoMessage()

func (*ExprPb) Reset

func (m *ExprPb) Reset()

func (*ExprPb) Size

func (m *ExprPb) Size() (n int)

func (*ExprPb) String

func (m *ExprPb) String() string

func (*ExprPb) Unmarshal

func (m *ExprPb) Unmarshal(data []byte) error

type Func

type Func struct {
	Name       string        // name of func, lower-cased
	Aggregate  bool          // is this aggregate func?
	CustomFunc               // CustomFunc Is dynamic function that can be registered
	Eval       EvaluatorFunc // The memoized evaluation function
}

Func Describes a function expression which wraps and allows native go functions to be called in expression vm

type FuncNode

type FuncNode struct {
	Name    string        // Name of func
	F       Func          // The actual function that this AST maps to
	Eval    EvaluatorFunc // the evaluator function
	Missing bool
	Args    []Node // Arguments are them-selves nodes
}

FuncNode holds a Func, which desribes a go Function as well as fulfilling the Pos, String() etc for a Node

func NewFuncNode

func NewFuncNode(name string, f Func) *FuncNode

NewFuncNode create new Function Expression Node.

func (*FuncNode) ChildrenArgs

func (m *FuncNode) ChildrenArgs() []Node

func (*FuncNode) Equal

func (m *FuncNode) Equal(n Node) bool

func (*FuncNode) Expr

func (m *FuncNode) Expr() *Expr

Expr convert the FuncNode to Expr

func (*FuncNode) FromExpr

func (m *FuncNode) FromExpr(e *Expr) error

func (*FuncNode) FromPB

func (m *FuncNode) FromPB(n *NodePb) Node

func (*FuncNode) NodePb

func (m *FuncNode) NodePb() *NodePb

func (*FuncNode) NodeType

func (m *FuncNode) NodeType() string

func (*FuncNode) String

func (m *FuncNode) String() string

func (*FuncNode) Validate

func (m *FuncNode) Validate() error

func (*FuncNode) WriteDialect

func (m *FuncNode) WriteDialect(w DialectWriter)

type FuncNodePb

type FuncNodePb struct {
	Name             string   `protobuf:"bytes,1,req,name=name" json:"name"`
	Args             []NodePb `protobuf:"bytes,2,rep,name=args" json:"args"`
	XXX_unrecognized []byte   `json:"-"`
}

Func Node, args are children

func (*FuncNodePb) Descriptor

func (*FuncNodePb) Descriptor() ([]byte, []int)

func (*FuncNodePb) Marshal

func (m *FuncNodePb) Marshal() (data []byte, err error)

func (*FuncNodePb) MarshalTo

func (m *FuncNodePb) MarshalTo(data []byte) (int, error)

func (*FuncNodePb) ProtoMessage

func (*FuncNodePb) ProtoMessage()

func (*FuncNodePb) Reset

func (m *FuncNodePb) Reset()

func (*FuncNodePb) Size

func (m *FuncNodePb) Size() (n int)

func (*FuncNodePb) String

func (m *FuncNodePb) String() string

func (*FuncNodePb) Unmarshal

func (m *FuncNodePb) Unmarshal(data []byte) error

type FuncRegistry

type FuncRegistry struct {
	// contains filtered or unexported fields
}

FuncRegistry contains lists of functions for different scope/run-time evaluation contexts.

func NewFuncRegistry

func NewFuncRegistry() *FuncRegistry

NewFuncRegistry create a new function registry. By default their is a global one, but you can have local function registries as well.

func (*FuncRegistry) Add

func (m *FuncRegistry) Add(name string, fn CustomFunc)

Add a name/function to registry

func (*FuncRegistry) FuncGet

func (m *FuncRegistry) FuncGet(name string) (Func, bool)

FuncGet gets a function from registry if it exists.

type FuncResolver

type FuncResolver interface {
	FuncGet(name string) (Func, bool)
}

FuncResolver is a function resolution interface that allows local/namespaced function resolution.

type IdentityNode

type IdentityNode struct {
	Quote byte
	Text  string
	// contains filtered or unexported fields
}

IdentityNode will look up a value out of a env bag also identities of sql objects (tables, columns, etc) we often need to rewrite these as in sql it is `table.column`

func NewIdentityNode

func NewIdentityNode(tok *lex.Token) *IdentityNode

func NewIdentityNodeVal

func NewIdentityNodeVal(val string) *IdentityNode

func (*IdentityNode) Bool

func (m *IdentityNode) Bool() bool

func (*IdentityNode) Equal

func (m *IdentityNode) Equal(n Node) bool

func (*IdentityNode) Expr

func (m *IdentityNode) Expr() *Expr

func (*IdentityNode) FromExpr

func (m *IdentityNode) FromExpr(e *Expr) error

func (*IdentityNode) FromPB

func (m *IdentityNode) FromPB(n *NodePb) Node

func (*IdentityNode) HasLeftRight

func (m *IdentityNode) HasLeftRight() bool

HasLeftRight Return bool if is of form `table.column` or `schema`.`table`

func (*IdentityNode) IdentityPb

func (m *IdentityNode) IdentityPb() *IdentityNodePb

func (*IdentityNode) IsBooleanIdentity

func (m *IdentityNode) IsBooleanIdentity() bool

func (*IdentityNode) LeftRight

func (m *IdentityNode) LeftRight() (string, string, bool)

Return left, right values if is of form `table.column` or `schema`.`table` and also return true/false for if it even has left & right syntax

func (*IdentityNode) NodePb

func (m *IdentityNode) NodePb() *NodePb

func (*IdentityNode) NodeType

func (m *IdentityNode) NodeType() string

func (*IdentityNode) OriginalText

func (m *IdentityNode) OriginalText() string

func (*IdentityNode) String

func (m *IdentityNode) String() string

func (*IdentityNode) Validate

func (m *IdentityNode) Validate() error

func (*IdentityNode) WriteDialect

func (m *IdentityNode) WriteDialect(w DialectWriter)

type IdentityNodePb

type IdentityNodePb struct {
	Quote            *int32 `protobuf:"varint,1,opt,name=quote" json:"quote,omitempty"`
	Text             string `protobuf:"bytes,3,opt,name=text" json:"text"`
	XXX_unrecognized []byte `json:"-"`
}

Identity

func (*IdentityNodePb) Descriptor

func (*IdentityNodePb) Descriptor() ([]byte, []int)

func (*IdentityNodePb) Marshal

func (m *IdentityNodePb) Marshal() (data []byte, err error)

func (*IdentityNodePb) MarshalTo

func (m *IdentityNodePb) MarshalTo(data []byte) (int, error)

func (*IdentityNodePb) ProtoMessage

func (*IdentityNodePb) ProtoMessage()

func (*IdentityNodePb) Reset

func (m *IdentityNodePb) Reset()

func (*IdentityNodePb) Size

func (m *IdentityNodePb) Size() (n int)

func (*IdentityNodePb) String

func (m *IdentityNodePb) String() string

func (*IdentityNodePb) Unmarshal

func (m *IdentityNodePb) Unmarshal(data []byte) error

type IdentityNodes

type IdentityNodes []*IdentityNode

IdentityNodes is a list of identities

func FindAllIdentities

func FindAllIdentities(node Node) IdentityNodes

FindAllIdentities gets all identity

func (IdentityNodes) LeftStrings

func (m IdentityNodes) LeftStrings() []string

LeftStrings get all Left Identity fields.

func (IdentityNodes) Strings

func (m IdentityNodes) Strings() []string

Strings get all identity strings

type IncludeContext

type IncludeContext struct {
	ContextReader
}

IncludeContext A ContextReader that implements Include interface.

func NewIncludeContext

func NewIncludeContext(cr ContextReader) *IncludeContext

NewIncludeContext a new IncludeContext from contextreader.

func (*IncludeContext) Include

func (*IncludeContext) Include(name string) (Node, error)

Include interface not implemented.

type IncludeNode

type IncludeNode struct {
	ExprNode Node // The expression of the referred to include
	Identity *IdentityNode
	Operator lex.Token
	// contains filtered or unexported fields
}

IncludeNode references a named node

(  ! INCLUDE <identity>  |  INCLUDE <identity> | NOT INCLUDE <identity> )

func NewInclude

func NewInclude(operator lex.Token, id *IdentityNode) *IncludeNode

Include nodes

NOT INCLUDE <identity>
! INCLUDE <identity>
INCLUDE <identity>

func (*IncludeNode) Collapse

func (m *IncludeNode) Collapse() Node

func (*IncludeNode) Equal

func (m *IncludeNode) Equal(n Node) bool

func (*IncludeNode) Expr

func (m *IncludeNode) Expr() *Expr

func (*IncludeNode) FromExpr

func (m *IncludeNode) FromExpr(e *Expr) error

func (*IncludeNode) FromPB

func (m *IncludeNode) FromPB(n *NodePb) Node

func (*IncludeNode) Negated

func (m *IncludeNode) Negated() bool

func (*IncludeNode) NodePb

func (m *IncludeNode) NodePb() *NodePb

func (*IncludeNode) NodeType

func (m *IncludeNode) NodeType() string

func (*IncludeNode) ReverseNegation

func (m *IncludeNode) ReverseNegation() bool

func (*IncludeNode) String

func (m *IncludeNode) String() string

func (*IncludeNode) StringNegate

func (m *IncludeNode) StringNegate() string

func (*IncludeNode) Validate

func (m *IncludeNode) Validate() error

func (*IncludeNode) WriteDialect

func (m *IncludeNode) WriteDialect(w DialectWriter)

func (*IncludeNode) WriteNegate

func (m *IncludeNode) WriteNegate(w DialectWriter)

type IncludeNodePb

type IncludeNodePb struct {
	Op               int32          `protobuf:"varint,1,req,name=op" json:"op"`
	Negated          bool           `protobuf:"varint,2,req,name=negated" json:"negated"`
	Identity         IdentityNodePb `protobuf:"bytes,3,req,name=identity" json:"identity"`
	XXX_unrecognized []byte         `json:"-"`
}

Include Node, two child args

func (*IncludeNodePb) Descriptor

func (*IncludeNodePb) Descriptor() ([]byte, []int)

func (*IncludeNodePb) Marshal

func (m *IncludeNodePb) Marshal() (data []byte, err error)

func (*IncludeNodePb) MarshalTo

func (m *IncludeNodePb) MarshalTo(data []byte) (int, error)

func (*IncludeNodePb) ProtoMessage

func (*IncludeNodePb) ProtoMessage()

func (*IncludeNodePb) Reset

func (m *IncludeNodePb) Reset()

func (*IncludeNodePb) Size

func (m *IncludeNodePb) Size() (n int)

func (*IncludeNodePb) String

func (m *IncludeNodePb) String() string

func (*IncludeNodePb) Unmarshal

func (m *IncludeNodePb) Unmarshal(data []byte) error

type Includer

type Includer interface {
	Include(name string) (Node, error)
}

Includer defines an interface used for resolving INCLUDE clauses into a Indclude reference. Implementations should return an error if the name cannot be resolved.

type LexTokenPager

type LexTokenPager struct {
	// contains filtered or unexported fields
}

TokenPager is responsible for determining end of current tree (column, etc)

func NewLexTokenPager

func NewLexTokenPager(lex *lex.Lexer) *LexTokenPager

func (*LexTokenPager) Backup

func (m *LexTokenPager) Backup()

backup backs the input stream up one token.

func (*LexTokenPager) ClauseEnd

func (m *LexTokenPager) ClauseEnd() bool

ClauseEnd are we at end of clause

func (*LexTokenPager) Cur

func (m *LexTokenPager) Cur() lex.Token

Returns the current token, does not advance

func (*LexTokenPager) ErrMsg

func (m *LexTokenPager) ErrMsg(msg string) error

func (*LexTokenPager) IsEnd

func (m *LexTokenPager) IsEnd() bool

IsEnd determines if pager is at end of statement

func (*LexTokenPager) Lexer

func (m *LexTokenPager) Lexer() *lex.Lexer

Lexer get the underlying lexer

func (*LexTokenPager) Next

func (m *LexTokenPager) Next() lex.Token

Next returns the current token and advances cursor to next one

func (*LexTokenPager) Peek

func (m *LexTokenPager) Peek() lex.Token

Peek returns but does not consume the next token.

type NegateableNode

type NegateableNode interface {
	// Node the negateable nodes also implement the entire Node
	Node
	// Negated Say if this node is negateable (it may not be), If the node
	// is negateable, we may collapse an surrounding negation into here
	Negated() bool
	// ReverseNegation if Possible:  for instance:
	//   "A" NOT IN ("a","b")    =>  "A" IN ("a","b")
	ReverseNegation() bool
	// StringNegate
	StringNegate() string
	// WriteNegate write out this node into a writer
	WriteNegate(w DialectWriter)
	// Collapse Negateable nodes may be collapsed logically into new nodes
	// return this node collapsed down to simpliest form
	Collapse() Node
}

NegateableNode A negateable node requires a special type of String() function due to an enclosing urnary NOT being inserted into middle of string syntax

<expression> [NOT] IN ("a","b")
<expression> [NOT] BETWEEN <expression> AND <expression>
<expression> [NOT] LIKE <expression>
<expression> [NOT] CONTAINS <expression>
<expression> [NOT] INTERSECTS ("a", "b")

type Node

type Node interface {
	// String representation of Node parseable back to itself
	String() string

	// WriteDialect Given a dialect writer write out, equivalent of String()
	// but allows different escape characters
	WriteDialect(w DialectWriter)

	// Validate Syntax validation of this expression node
	Validate() error

	// NodePb Convert this node to a Protobuf copy of it
	NodePb() *NodePb
	// FromPB Convert a protobuf presentation of node to Node.
	FromPB(*NodePb) Node

	// Expr Convert node into a simple expression syntax
	// which can be used for json respresentation
	Expr() *Expr
	// FromExpr
	FromExpr(*Expr) error

	// Equal compares deep equality of
	Equal(Node) bool

	// NodeType the String, Identity, etc
	NodeType() string
}

Node is a node in an expression tree, implemented by different types (binary, urnary, func, identity, etc)

qlbridge does not currently implement statements (if, for, switch, etc) just expressions, and operators

func InlineIncludes

func InlineIncludes(ctx Includer, n Node) (Node, error)

InlineIncludes take an expression and resolve any includes so that the included expression is "Inline"

func MustParse

func MustParse(expressionText string) Node

MustParse parse a single Expression, returning an Expression Node and panics if it cannot be parsed

MustParse("5 * toint(item_name)")

func NewUnary

func NewUnary(operator lex.Token, arg Node) Node

Unary nodes

NOT <expression>
! <expression>
EXISTS <identity>
<identity> IS NOT NULL

func NodeFromExpr

func NodeFromExpr(e *Expr) (Node, error)

func NodeFromNodePb

func NodeFromNodePb(n *NodePb) Node

NodeFromNodePb Create a node from pb

func NodeFromPb

func NodeFromPb(pb []byte) (Node, error)

NodeFromPb Create a node from pb

func NodesFromExprs

func NodesFromExprs(args []*Expr) ([]Node, error)

func NodesFromNodesPb

func NodesFromNodesPb(pb []NodePb) []Node

func NodesFromNodesPbPtr

func NodesFromNodesPbPtr(pb []*NodePb) []Node

func ParseExprWithFuncs

func ParseExprWithFuncs(p TokenPager, fr FuncResolver) (Node, error)

Parse a single Expression, returning an Expression Node

@fr = function registry with any additional functions

ParseExprWithFuncs("5 * toint(item_name)", funcRegistry)

func ParseExpression

func ParseExpression(expressionText string) (Node, error)

ParseExpression parse a single Expression, returning an Expression Node

ParseExpression("5 * toint(item_name)")

func ParsePager

func ParsePager(pager TokenPager) (Node, error)

Parse a single Expression, returning an Expression Node

@pager = Token Pager

type NodeArgs

type NodeArgs interface {
	ChildrenArgs() []Node
}

NodeArgs is an interface for nodes which have child arguments

type NodePb

type NodePb struct {
	Bn               *BinaryNodePb   `protobuf:"bytes,1,opt,name=bn" json:"bn,omitempty"`
	Booln            *BooleanNodePb  `protobuf:"bytes,2,opt,name=booln" json:"booln,omitempty"`
	Un               *UnaryNodePb    `protobuf:"bytes,3,opt,name=un" json:"un,omitempty"`
	Fn               *FuncNodePb     `protobuf:"bytes,4,opt,name=fn" json:"fn,omitempty"`
	Tn               *TriNodePb      `protobuf:"bytes,5,opt,name=tn" json:"tn,omitempty"`
	An               *ArrayNodePb    `protobuf:"bytes,6,opt,name=an" json:"an,omitempty"`
	Nn               *NumberNodePb   `protobuf:"bytes,10,opt,name=nn" json:"nn,omitempty"`
	Vn               *ValueNodePb    `protobuf:"bytes,11,opt,name=vn" json:"vn,omitempty"`
	In               *IdentityNodePb `protobuf:"bytes,12,opt,name=in" json:"in,omitempty"`
	Sn               *StringNodePb   `protobuf:"bytes,13,opt,name=sn" json:"sn,omitempty"`
	Incn             *IncludeNodePb  `protobuf:"bytes,14,opt,name=incn" json:"incn,omitempty"`
	Niln             *NullNodePb     `protobuf:"bytes,15,opt,name=niln" json:"niln,omitempty"`
	XXX_unrecognized []byte          `json:"-"`
}

The generic Node, must be exactly one of these types

func NodesPbFromNodes

func NodesPbFromNodes(nodes []Node) []*NodePb

func (*NodePb) Descriptor

func (*NodePb) Descriptor() ([]byte, []int)

func (*NodePb) Marshal

func (m *NodePb) Marshal() (data []byte, err error)

func (*NodePb) MarshalTo

func (m *NodePb) MarshalTo(data []byte) (int, error)

func (*NodePb) ProtoMessage

func (*NodePb) ProtoMessage()

func (*NodePb) Reset

func (m *NodePb) Reset()

func (*NodePb) Size

func (m *NodePb) Size() (n int)

func (*NodePb) String

func (m *NodePb) String() string

func (*NodePb) Unmarshal

func (m *NodePb) Unmarshal(data []byte) error

type NullNode

type NullNode struct{}

NullNode is a simple NULL type node

func NewNull

func NewNull(operator lex.Token) *NullNode

func (*NullNode) Equal

func (m *NullNode) Equal(n Node) bool

func (*NullNode) Expr

func (m *NullNode) Expr() *Expr

func (*NullNode) FromExpr

func (m *NullNode) FromExpr(e *Expr) error

func (*NullNode) FromPB

func (m *NullNode) FromPB(n *NodePb) Node

func (*NullNode) NodePb

func (m *NullNode) NodePb() *NodePb

func (*NullNode) NodeType

func (m *NullNode) NodeType() string

func (*NullNode) String

func (m *NullNode) String() string

func (*NullNode) Validate

func (m *NullNode) Validate() error

func (*NullNode) WriteDialect

func (m *NullNode) WriteDialect(w DialectWriter)

type NullNodePb

type NullNodePb struct {
	Niltype          int32  `protobuf:"varint,1,opt,name=niltype" json:"niltype"`
	XXX_unrecognized []byte `json:"-"`
}

NullNode

func (*NullNodePb) Descriptor

func (*NullNodePb) Descriptor() ([]byte, []int)

func (*NullNodePb) Marshal

func (m *NullNodePb) Marshal() (data []byte, err error)

func (*NullNodePb) MarshalTo

func (m *NullNodePb) MarshalTo(data []byte) (int, error)

func (*NullNodePb) ProtoMessage

func (*NullNodePb) ProtoMessage()

func (*NullNodePb) Reset

func (m *NullNodePb) Reset()

func (*NullNodePb) Size

func (m *NullNodePb) Size() (n int)

func (*NullNodePb) String

func (m *NullNodePb) String() string

func (*NullNodePb) Unmarshal

func (m *NullNodePb) Unmarshal(data []byte) error

type NumberNode

type NumberNode struct {
	IsInt   bool    // Number has an integer value.
	IsFloat bool    // Number has a floating-point value.
	Int64   int64   // The integer value.
	Float64 float64 // The floating-point value.
	Text    string  // The original textual representation from the input.
}

NumberNode holds a number: signed or unsigned integer or float. The value is parsed and stored under all the types that can represent the value. This simulates in a small amount of code the behavior of Go's ideal constants.

func NewNumber

func NewNumber(fv float64) (*NumberNode, error)

func NewNumberStr

func NewNumberStr(text string) (*NumberNode, error)

NewNumberStr is a little weird in that this Node accepts string @text and uses go to parse into Int, AND Float.

func (*NumberNode) Equal

func (m *NumberNode) Equal(n Node) bool

func (*NumberNode) Expr

func (m *NumberNode) Expr() *Expr

func (*NumberNode) FromExpr

func (m *NumberNode) FromExpr(e *Expr) error

func (*NumberNode) FromPB

func (m *NumberNode) FromPB(n *NodePb) Node

func (*NumberNode) NodePb

func (m *NumberNode) NodePb() *NodePb

func (*NumberNode) NodeType

func (m *NumberNode) NodeType() string

func (*NumberNode) String

func (n *NumberNode) String() string

func (*NumberNode) Validate

func (m *NumberNode) Validate() error

func (*NumberNode) WriteDialect

func (m *NumberNode) WriteDialect(w DialectWriter)

type NumberNodePb

type NumberNodePb struct {
	Isint            bool    `protobuf:"varint,1,opt,name=isint" json:"isint"`
	Isfloat          bool    `protobuf:"varint,2,opt,name=isfloat" json:"isfloat"`
	Iv               int64   `protobuf:"varint,3,req,name=iv" json:"iv"`
	Fv               float64 `protobuf:"fixed64,4,req,name=fv" json:"fv"`
	Text             string  `protobuf:"bytes,5,req,name=text" json:"text"`
	XXX_unrecognized []byte  `json:"-"`
}

Number Node

func (*NumberNodePb) Descriptor

func (*NumberNodePb) Descriptor() ([]byte, []int)

func (*NumberNodePb) Marshal

func (m *NumberNodePb) Marshal() (data []byte, err error)

func (*NumberNodePb) MarshalTo

func (m *NumberNodePb) MarshalTo(data []byte) (int, error)

func (*NumberNodePb) ProtoMessage

func (*NumberNodePb) ProtoMessage()

func (*NumberNodePb) Reset

func (m *NumberNodePb) Reset()

func (*NumberNodePb) Size

func (m *NumberNodePb) Size() (n int)

func (*NumberNodePb) String

func (m *NumberNodePb) String() string

func (*NumberNodePb) Unmarshal

func (m *NumberNodePb) Unmarshal(data []byte) error

type RowWriter

type RowWriter interface {
	// Commit the given rowInfo to persist
	Commit(rowInfo []SchemaInfo, row RowWriter) error
	// Put (persist) given Column info write single column.
	Put(col SchemaInfo, readCtx ContextReader, v value.Value) error
}

RowWriter for committing row ops (insert, update)

type SchemaInfo

type SchemaInfo interface {
	Key() string
}

SchemaInfo is interface for a Column type

type SchemaInfoString

type SchemaInfoString string

SchemaInfoString implements schemaInfo Key()

func (SchemaInfoString) Key

func (m SchemaInfoString) Key() string

type StringNode

type StringNode struct {
	Quote byte
	Text  string
	// contains filtered or unexported fields
}

StringNode holds a value literal, quotes not included

func NewStringNeedsEscape

func NewStringNeedsEscape(t lex.Token) *StringNode

func NewStringNoQuoteNode

func NewStringNoQuoteNode(text string) *StringNode

func NewStringNode

func NewStringNode(text string) *StringNode

func NewStringNodeToken

func NewStringNodeToken(t lex.Token) *StringNode

func (*StringNode) Equal

func (m *StringNode) Equal(n Node) bool

func (*StringNode) Expr

func (m *StringNode) Expr() *Expr

func (*StringNode) FromExpr

func (m *StringNode) FromExpr(e *Expr) error

func (*StringNode) FromPB

func (m *StringNode) FromPB(n *NodePb) Node

func (*StringNode) NodePb

func (m *StringNode) NodePb() *NodePb

func (*StringNode) NodeType

func (m *StringNode) NodeType() string

func (*StringNode) String

func (m *StringNode) String() string

func (*StringNode) Validate

func (m *StringNode) Validate() error

func (*StringNode) WriteDialect

func (m *StringNode) WriteDialect(w DialectWriter)

type StringNodePb

type StringNodePb struct {
	Noquote          *bool  `protobuf:"varint,1,opt,name=noquote" json:"noquote,omitempty"`
	Quote            *int32 `protobuf:"varint,2,opt,name=quote" json:"quote,omitempty"`
	Text             string `protobuf:"bytes,3,opt,name=text" json:"text"`
	XXX_unrecognized []byte `json:"-"`
}

String literal, no children

func (*StringNodePb) Descriptor

func (*StringNodePb) Descriptor() ([]byte, []int)

func (*StringNodePb) Marshal

func (m *StringNodePb) Marshal() (data []byte, err error)

func (*StringNodePb) MarshalTo

func (m *StringNodePb) MarshalTo(data []byte) (int, error)

func (*StringNodePb) ProtoMessage

func (*StringNodePb) ProtoMessage()

func (*StringNodePb) Reset

func (m *StringNodePb) Reset()

func (*StringNodePb) Size

func (m *StringNodePb) Size() (n int)

func (*StringNodePb) String

func (m *StringNodePb) String() string

func (*StringNodePb) Unmarshal

func (m *StringNodePb) Unmarshal(data []byte) error

type TokenPager

type TokenPager interface {
	Peek() lex.Token
	Next() lex.Token
	Cur() lex.Token
	Backup()
	IsEnd() bool
	ClauseEnd() bool
	Lexer() *lex.Lexer
	ErrMsg(msg string) error
}

TokenPager wraps a Lexer, and implements the Logic to determine what is the end of this particular clause. Lexer's are stateless, while tokenpager implements state ontop of pager and allows forward/back etc

type TriNode

type TriNode struct {
	Args     []Node
	Operator lex.Token
	// contains filtered or unexported fields
}

TriNode 3 part expression such as

ARG1 Between ARG2 AND ARG3

func NewTriNode

func NewTriNode(operator lex.Token, arg1, arg2, arg3 Node) *TriNode

Create a Tri node

@arg1 [NOT] BETWEEN @arg2 AND @arg3

func (*TriNode) ChildrenArgs

func (m *TriNode) ChildrenArgs() []Node

func (*TriNode) Collapse

func (m *TriNode) Collapse() Node

func (*TriNode) Equal

func (m *TriNode) Equal(n Node) bool

func (*TriNode) Expr

func (m *TriNode) Expr() *Expr

func (*TriNode) FromExpr

func (m *TriNode) FromExpr(e *Expr) error

func (*TriNode) FromPB

func (m *TriNode) FromPB(n *NodePb) Node

func (*TriNode) Negated

func (m *TriNode) Negated() bool

func (*TriNode) NodePb

func (m *TriNode) NodePb() *NodePb

func (*TriNode) NodeType

func (m *TriNode) NodeType() string

func (*TriNode) ReverseNegation

func (m *TriNode) ReverseNegation() bool

func (*TriNode) String

func (m *TriNode) String() string

func (*TriNode) StringNegate

func (m *TriNode) StringNegate() string

func (*TriNode) Validate

func (m *TriNode) Validate() error

func (*TriNode) WriteDialect

func (m *TriNode) WriteDialect(w DialectWriter)

func (*TriNode) WriteNegate

func (m *TriNode) WriteNegate(w DialectWriter)

type TriNodePb

type TriNodePb struct {
	Op               int32    `protobuf:"varint,1,req,name=op" json:"op"`
	Args             []NodePb `protobuf:"bytes,2,rep,name=args" json:"args"`
	XXX_unrecognized []byte   `json:"-"`
}

Tri Node, may hve children

func (*TriNodePb) Descriptor

func (*TriNodePb) Descriptor() ([]byte, []int)

func (*TriNodePb) Marshal

func (m *TriNodePb) Marshal() (data []byte, err error)

func (*TriNodePb) MarshalTo

func (m *TriNodePb) MarshalTo(data []byte) (int, error)

func (*TriNodePb) ProtoMessage

func (*TriNodePb) ProtoMessage()

func (*TriNodePb) Reset

func (m *TriNodePb) Reset()

func (*TriNodePb) Size

func (m *TriNodePb) Size() (n int)

func (*TriNodePb) String

func (m *TriNodePb) String() string

func (*TriNodePb) Unmarshal

func (m *TriNodePb) Unmarshal(data []byte) error

type UnaryNode

type UnaryNode struct {
	Arg      Node
	Operator lex.Token
}

UnaryNode negates a single node argument

(  not <expression>  |   !<expression> )

!eq(5,6)
!true
!(true OR false)
!toint(now())

func (*UnaryNode) ChildrenArgs

func (m *UnaryNode) ChildrenArgs() []Node

func (*UnaryNode) Collapse

func (m *UnaryNode) Collapse() Node

func (*UnaryNode) Equal

func (m *UnaryNode) Equal(n Node) bool

func (*UnaryNode) Expr

func (m *UnaryNode) Expr() *Expr

func (*UnaryNode) FromExpr

func (m *UnaryNode) FromExpr(e *Expr) error

func (*UnaryNode) FromPB

func (m *UnaryNode) FromPB(n *NodePb) Node

func (*UnaryNode) NodePb

func (m *UnaryNode) NodePb() *NodePb

func (*UnaryNode) NodeType

func (m *UnaryNode) NodeType() string

func (*UnaryNode) String

func (m *UnaryNode) String() string

func (*UnaryNode) Validate

func (m *UnaryNode) Validate() error

func (*UnaryNode) WriteDialect

func (m *UnaryNode) WriteDialect(w DialectWriter)

type UnaryNodePb

type UnaryNodePb struct {
	Op               int32  `protobuf:"varint,1,req,name=op" json:"op"`
	Paren            bool   `protobuf:"varint,2,opt,name=paren" json:"paren"`
	Arg              NodePb `protobuf:"bytes,3,req,name=arg" json:"arg"`
	XXX_unrecognized []byte `json:"-"`
}

Unary Node, one child

func (*UnaryNodePb) Descriptor

func (*UnaryNodePb) Descriptor() ([]byte, []int)

func (*UnaryNodePb) Marshal

func (m *UnaryNodePb) Marshal() (data []byte, err error)

func (*UnaryNodePb) MarshalTo

func (m *UnaryNodePb) MarshalTo(data []byte) (int, error)

func (*UnaryNodePb) ProtoMessage

func (*UnaryNodePb) ProtoMessage()

func (*UnaryNodePb) Reset

func (m *UnaryNodePb) Reset()

func (*UnaryNodePb) Size

func (m *UnaryNodePb) Size() (n int)

func (*UnaryNodePb) String

func (m *UnaryNodePb) String() string

func (*UnaryNodePb) Unmarshal

func (m *UnaryNodePb) Unmarshal(data []byte) error

type ValueNode

type ValueNode struct {
	Value value.Value
	// contains filtered or unexported fields
}

ValueNode holds a value.Value type value.Values can be strings, numbers, arrays, objects, etc

func NewValueNode

func NewValueNode(val value.Value) *ValueNode

func (*ValueNode) Equal

func (m *ValueNode) Equal(n Node) bool

func (*ValueNode) Expr

func (m *ValueNode) Expr() *Expr

func (*ValueNode) FromExpr

func (m *ValueNode) FromExpr(e *Expr) error

func (*ValueNode) FromPB

func (m *ValueNode) FromPB(n *NodePb) Node

func (*ValueNode) IsArray

func (m *ValueNode) IsArray() bool

func (*ValueNode) NodePb

func (m *ValueNode) NodePb() *NodePb

func (*ValueNode) NodeType

func (m *ValueNode) NodeType() string

func (*ValueNode) String

func (m *ValueNode) String() string

func (*ValueNode) Validate

func (m *ValueNode) Validate() error

func (*ValueNode) WriteDialect

func (m *ValueNode) WriteDialect(w DialectWriter)

type ValueNodePb

type ValueNodePb struct {
	Valuetype        int32  `protobuf:"varint,1,req,name=valuetype" json:"valuetype"`
	Value            []byte `protobuf:"bytes,2,req,name=value" json:"value,omitempty"`
	XXX_unrecognized []byte `json:"-"`
}

Value Node

func (*ValueNodePb) Descriptor

func (*ValueNodePb) Descriptor() ([]byte, []int)

func (*ValueNodePb) Marshal

func (m *ValueNodePb) Marshal() (data []byte, err error)

func (*ValueNodePb) MarshalTo

func (m *ValueNodePb) MarshalTo(data []byte) (int, error)

func (*ValueNodePb) ProtoMessage

func (*ValueNodePb) ProtoMessage()

func (*ValueNodePb) Reset

func (m *ValueNodePb) Reset()

func (*ValueNodePb) Size

func (m *ValueNodePb) Size() (n int)

func (*ValueNodePb) String

func (m *ValueNodePb) String() string

func (*ValueNodePb) Unmarshal

func (m *ValueNodePb) Unmarshal(data []byte) error

Directories

Path Synopsis
Builtin functions are a library of functions natively available in qlbridge expression evaluation although adding your own is easy.
Builtin functions are a library of functions natively available in qlbridge expression evaluation although adding your own is easy.

Jump to

Keyboard shortcuts

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