Documentation ¶
Index ¶
- Constants
- Variables
- func BinaryExprName(expr *BinaryExpr) string
- func ContainsVarRef(expr Expr) bool
- func Eval(expr Expr, js *string) interface{}
- func EvalBool(expr Expr, js *string) bool
- func EvalSQL(sql string, docs []string) map[string]Points
- func IdentNeedsQuotes(ident string) bool
- func IsListOp(t Token) bool
- func IsRegexOp(t Token) bool
- func MatchSource(sources Sources, name string) string
- func QuoteIdent(segments ...string) string
- func QuoteString(s string) string
- func ScanBareIdent(r io.RuneScanner) string
- func ScanDelimited(r io.RuneScanner, start, end rune, escapes map[rune]rune, escapesPassThru bool) ([]byte, error)
- func ScanString(r io.RuneScanner) (string, error)
- func Walk(v Visitor, node Node)
- func WalkFunc(node Node, fn func(Node))
- type BinaryExpr
- type BooleanLiteral
- type Call
- type DataType
- type Dimension
- type Dimensions
- type Expr
- type Field
- type Fields
- type HasDefaultDatabase
- type IntegerLiteral
- type ListLiteral
- type Literal
- type Measurement
- type Measurements
- type Node
- type NowValuer
- type NumberLiteral
- type ParenExpr
- type ParseError
- type Parser
- type Points
- type Pos
- type RegexLiteral
- type Rewriter
- type Scanner
- type SelectStatement
- func (s *SelectStatement) Clone() *SelectStatement
- func (s *SelectStatement) ColumnNames() []string
- func (s *SelectStatement) FlatStatByGroup(docs []string) map[string]*SelectStatement
- func (s *SelectStatement) FunctionCalls() []*Call
- func (s *SelectStatement) FunctionCallsByPosition() [][]*Call
- func (s *SelectStatement) NamesInSelect() []string
- func (s *SelectStatement) NamesInWhere() []string
- func (s *SelectStatement) String() string
- type Source
- type Sources
- type Statement
- type Statements
- type StringLiteral
- type Token
- type Valuer
- type VarRef
- type VarRefs
- type Visitor
Constants ¶
const ( // Unknown primitive data type. Unknown DataType = 0 // Float means the data type is a float Float = 1 // Integer means the data type is a integer Integer = 2 // String means the data type is a string of text. String = 3 // Boolean means the data type is a boolean. Boolean = 4 // AnyField means the data type is any field. AnyField = 5 )
Variables ¶
var ( // ErrInvalidTime is returned when the timestamp string used to // compare against time field is invalid. ErrInvalidTime = errors.New("invalid timestamp string") )
Functions ¶
func BinaryExprName ¶
func BinaryExprName(expr *BinaryExpr) string
BinaryExprName returns the name of a binary expression by concatenating the variables in the binary expression with underscores.
func ContainsVarRef ¶
ContainsVarRef returns true if expr is a VarRef or contains one.
func EvalBool ¶
EvalBool evaluates expr and returns true if result is a boolean true. Otherwise returns false.
func IdentNeedsQuotes ¶
IdentNeedsQuotes returns true if the ident string given would require quotes.
func MatchSource ¶
MatchSource returns the source name that matches a field name. Returns a blank string if no sources match.
func QuoteIdent ¶
QuoteIdent returns a quoted identifier from multiple bare identifiers.
func ScanBareIdent ¶
func ScanBareIdent(r io.RuneScanner) string
ScanBareIdent reads bare identifier from a rune reader.
func ScanDelimited ¶
func ScanDelimited(r io.RuneScanner, start, end rune, escapes map[rune]rune, escapesPassThru bool) ([]byte, error)
ScanDelimited reads a delimited set of runes
func ScanString ¶
func ScanString(r io.RuneScanner) (string, error)
ScanString reads a quoted string from a rune reader.
Types ¶
type BinaryExpr ¶
BinaryExpr represents an operation between two expressions.
func (*BinaryExpr) String ¶
func (e *BinaryExpr) String() string
String returns a string representation of the binary expression.
type BooleanLiteral ¶
type BooleanLiteral struct {
Val bool
}
BooleanLiteral represents a boolean literal.
func (*BooleanLiteral) String ¶
func (l *BooleanLiteral) String() string
String returns a string representation of the literal.
type Call ¶
type Call struct { Name string Args []Expr // must hava not funcCall expr First bool Count int // contains filtered or unexported fields }
Call represents a function call.
type DataType ¶
type DataType int
DataType represents the primitive data types available in InfluxQL.
func InspectDataType ¶
func InspectDataType(v interface{}) DataType
InspectDataType returns the data type of a given value.
func InspectDataTypes ¶
func InspectDataTypes(a []interface{}) []DataType
InspectDataTypes returns all of the data types for an interface slice.
type Dimension ¶
type Dimension struct {
Expr Expr
}
Dimension represents an expression that a select statement is grouped by.
type Dimensions ¶
type Dimensions []*Dimension
Dimensions represents a list of dimensions.
func (Dimensions) String ¶
func (a Dimensions) String() string
String returns a string representation of the dimensions.
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expr represents an expression that can be evaluated to a value.
type Field ¶
Field represents an expression retrieved from a select statement.
type Fields ¶
type Fields []*Field
Fields represents a list of fields.
func (Fields) AliasNames ¶
AliasNames returns a list of calculated field names in order of alias, function name, then field.
type HasDefaultDatabase ¶
type HasDefaultDatabase interface { Node DefaultDatabase() string // contains filtered or unexported methods }
HasDefaultDatabase provides an interface to get the default database from a Statement.
type IntegerLiteral ¶
type IntegerLiteral struct {
Val int64
}
IntegerLiteral represents an integer literal.
func (*IntegerLiteral) String ¶
func (l *IntegerLiteral) String() string
String returns a string representation of the literal.
type ListLiteral ¶
type ListLiteral struct {
Vals []interface{}
}
ListLiteral represents a list of strings literal.
func (*ListLiteral) String ¶
func (s *ListLiteral) String() string
String returns a string representation of the literal.
type Literal ¶
type Literal interface { Expr // contains filtered or unexported methods }
Literal represents a static literal.
type Measurement ¶
type Measurement struct {
Database string
}
Measurement represents a single measurement used as a datasource.
func (*Measurement) String ¶
func (m *Measurement) String() string
String returns a string representation of the measurement.
type Measurements ¶
type Measurements []*Measurement
Measurements represents a list of measurements.
func (Measurements) String ¶
func (a Measurements) String() string
String returns a string representation of the measurements.
type Node ¶
type Node interface { String() string // contains filtered or unexported methods }
Node represents a node in the InfluxDB abstract syntax tree.
type NumberLiteral ¶
type NumberLiteral struct {
Val float64
}
NumberLiteral represents a numeric literal.
func (*NumberLiteral) String ¶
func (l *NumberLiteral) String() string
String returns a string representation of the literal.
type ParenExpr ¶
type ParenExpr struct {
Expr Expr
}
ParenExpr represents a parenthesized expression.
type ParseError ¶
ParseError represents an error that occurred during parsing.
func (*ParseError) Error ¶
func (e *ParseError) Error() string
Error returns the string representation of the error.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents an InfluxQL parser.
func (*Parser) ParseStatement ¶
ParseStatement parses an InfluxQL string and returns a Statement AST object.
type Pos ¶
Pos specifies the line and character position of a token. The Char and Line are both zero-based indexes.
type RegexLiteral ¶
RegexLiteral represents a regular expression.
func CloneRegexLiteral ¶
func CloneRegexLiteral(r *RegexLiteral) *RegexLiteral
CloneRegexLiteral returns a clone of the RegexLiteral.
func (*RegexLiteral) String ¶
func (r *RegexLiteral) String() string
String returns a string representation of the literal.
type Rewriter ¶
Rewriter can be called by Rewrite to replace nodes in the AST hierarchy. The Rewrite() function is called once per node.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner represents a lexical scanner for InfluxQL.
func NewScanner ¶
NewScanner returns a new instance of Scanner.
type SelectStatement ¶
type SelectStatement struct { // Expressions returned from the selection. Fields Fields // Data sources that fields are extracted from. Sources Sources // An expression evaluated on data point. Condition Expr // Expressions used for grouping the selection. Dimensions Dimensions // if it's a query for raw data values (i.e. not an aggregate) IsRawQuery bool // Removes duplicate rows from raw queries. Dedupe bool Count int }
SelectStatement represents a command for extracting data from the database.
func (*SelectStatement) Clone ¶
func (s *SelectStatement) Clone() *SelectStatement
Clone returns a deep copy of the statement.
func (*SelectStatement) ColumnNames ¶
func (s *SelectStatement) ColumnNames() []string
ColumnNames will walk all fields and functions and return the appropriate field names for the select statement while maintaining order of the field names
func (*SelectStatement) FlatStatByGroup ¶
func (s *SelectStatement) FlatStatByGroup(docs []string) map[string]*SelectStatement
FlatStatByGroup divergent multi SelectStatement based on group by clause
func (*SelectStatement) FunctionCalls ¶
func (s *SelectStatement) FunctionCalls() []*Call
FunctionCalls returns the Call objects from the query
func (*SelectStatement) FunctionCallsByPosition ¶
func (s *SelectStatement) FunctionCallsByPosition() [][]*Call
FunctionCallsByPosition returns the Call objects from the query in the order they appear in the select statement
func (*SelectStatement) NamesInSelect ¶
func (s *SelectStatement) NamesInSelect() []string
NamesInSelect returns the field and tag names (idents) in the select clause
func (*SelectStatement) NamesInWhere ¶
func (s *SelectStatement) NamesInWhere() []string
NamesInWhere returns the field and tag names (idents) referenced in the where clause
func (*SelectStatement) String ¶
func (s *SelectStatement) String() string
String returns a string representation of the select statement.
type Source ¶
type Source interface { Node // contains filtered or unexported methods }
Source represents a source of data for a statement.
type Statement ¶
type Statement interface { Node // contains filtered or unexported methods }
Statement represents a single command in InfluxQL.
func ParseStatement ¶
ParseStatement parses a statement string and returns its AST representation.
type Statements ¶
type Statements []Statement
Statements represents a list of statements.
func (Statements) String ¶
func (a Statements) String() string
String returns a string representation of the statements.
type StringLiteral ¶
type StringLiteral struct {
Val string
}
StringLiteral represents a string literal.
func (*StringLiteral) String ¶
func (l *StringLiteral) String() string
String returns a string representation of the literal.
type Token ¶
type Token int
Token is a lexical token of the InfluxQL language.
const ( // ILLEGAL Token, EOF, WS are Special InfluxQL tokens. ILLEGAL Token = iota EOF WS // IDENT and the following are InfluxQL literal tokens. IDENT // main NUMBER // 12345.67 INTEGER // 12345 STRING // "abc" BADSTRING // "abc BADESCAPE // \q TRUE // true FALSE // false REGEX // Regular expressions BADREGEX // `.* // ADD and the following are InfluxQL Operators ADD // + SUB // - MUL // * DIV // / MOD // % AND // AND OR // OR NI // not in IN EQ // = NEQ // != EQREGEX // =~ NEQREGEX // !~ LT // < LTE // <= GT // > GTE // >= LBRACKET // [ LPAREN // ( RBRACKET // ] RPAREN // ) COMMA // , DOT // . ALL AS FROM SELECT WHERE GROUP BY )
These are a comprehensive list of InfluxQL language tokens.
func (Token) Precedence ¶
Precedence returns the operator precedence of the binary operator token.
type Valuer ¶
Valuer is the interface that wraps the Value() method.
Value returns the value and existence flag for a given key.