tql

package
v1.7.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String(expr Expr) string

Types

type AST

type AST interface {
	fmt.Stringer
}

func ParsePart

func ParsePart(s string) (AST, error)

type Attr

type Attr struct {
	Name string
}

func (Attr) AppendString

func (a Attr) AppendString(b []byte) []byte

type BinaryExpr

type BinaryExpr struct {
	Op       BinaryOp
	LHS, RHS Expr
}

func (*BinaryExpr) AppendString

func (e *BinaryExpr) AppendString(b []byte) []byte

type BinaryOp

type BinaryOp string

type BoolOp

type BoolOp string
const (
	BoolAnd BoolOp = "AND"
	BoolOr  BoolOp = "OR"
)

type Column

type Column struct {
	Value Expr
	Alias string
}

func ParseColumn

func ParseColumn(s string) (*Column, error)

func (*Column) AppendString

func (col *Column) AppendString(b []byte) []byte

type Columns

type Columns []Column

func (Columns) AppendString

func (cols Columns) AppendString(b []byte) []byte

type Expr

type Expr interface {
	AppendString([]byte) []byte
}

type Filter

type Filter struct {
	BoolOp BoolOp
	LHS    Expr
	Op     FilterOp
	RHS    Value
}

func (*Filter) AppendString

func (f *Filter) AppendString(b []byte) []byte

type FilterOp

type FilterOp string
const (
	FilterEqual    FilterOp = "="
	FilterNotEqual FilterOp = "!="

	FilterIn    FilterOp = "in"
	FilterNotIn FilterOp = "not in"

	FilterLike    FilterOp = "like"
	FilterNotLike FilterOp = "not like"

	FilterContains    FilterOp = "contains"
	FilterNotContains FilterOp = "not contains"

	FilterExists    FilterOp = "exists"
	FilterNotExists FilterOp = "not exists"

	// For compatibility with metrics.
	FilterRegexp    FilterOp = "~"
	FilterNotRegexp FilterOp = "!~"
)

type FuncCall

type FuncCall struct {
	Func string
	Arg  Expr
}

func (*FuncCall) AppendString

func (c *FuncCall) AppendString(b []byte) []byte

type Grouping

type Grouping struct {
	Columns
}

func (*Grouping) String

func (g *Grouping) String() string

type JSONError

type JSONError struct {
	Wrapped error
}

func (JSONError) MarshalJSON

func (e JSONError) MarshalJSON() ([]byte, error)

type NumberKind

type NumberKind int
const (
	NumberUnitless NumberKind = iota
	NumberDuration
	NumberBytes
)

type NumberValue

type NumberValue struct {
	Kind NumberKind
	Text string
}

func (NumberValue) AppendString

func (n NumberValue) AppendString(b []byte) []byte

func (NumberValue) String

func (n NumberValue) String() string

func (NumberValue) Values

func (v NumberValue) Values() []string

type ParenExpr

type ParenExpr struct {
	Expr
}

func (ParenExpr) AppendString

func (e ParenExpr) AppendString(b []byte) []byte

type QueryPart

type QueryPart struct {
	Query    string    `json:"query"`
	Error    JSONError `json:"error,omitempty"`
	Disabled bool      `json:"disabled,omitempty"`

	AST any `json:"-"`
}

func ParseQuery

func ParseQuery(s string) []*QueryPart

func ParseQueryError

func ParseQueryError(query string) ([]*QueryPart, error)

type Selector

type Selector struct {
	Columns
}

func (*Selector) String

func (sel *Selector) String() string

type StringValue

type StringValue struct {
	Text string
}

func (StringValue) AppendString

func (v StringValue) AppendString(b []byte) []byte

func (StringValue) String

func (v StringValue) String() string

func (StringValue) Values

func (v StringValue) Values() []string

type StringValues

type StringValues struct {
	Strings []string
}

func (StringValues) AppendString

func (v StringValues) AppendString(b []byte) []byte

func (StringValues) String

func (v StringValues) String() string

func (StringValues) Values

func (v StringValues) Values() []string

type Token

type Token struct {
	ID    TokenID
	Text  string
	Start int
}

func (*Token) String

func (t *Token) String() string

type TokenID

type TokenID int8

/go:generate stringer -type=TokenID

const (
	EOF_TOKEN TokenID = iota
	BYTE_TOKEN
	IDENT_TOKEN
	NUMBER_TOKEN
	DURATION_TOKEN
	BYTES_TOKEN
	VALUE_TOKEN
)

func (TokenID) String

func (i TokenID) String() string

type Value

type Value interface {
	fmt.Stringer
	AppendString([]byte) []byte
	Values() []string
}

func NewValue

func NewValue(v any) Value

type Where

type Where struct {
	Filters []Filter
}

func (*Where) String

func (w *Where) String() string

Jump to

Keyboard shortcuts

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