Documentation
¶
Index ¶
- Constants
- Variables
- func BinaryExprName(expr *BinaryExpr) string
- func CheckTime(t time.Time) error
- func ContainsVarRef(expr Expr) bool
- func EsDsl(sql string) (string, error)
- func GetPrecisionMultiplier(precision string) int64
- 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 SafeCalcTime(timestamp int64, precision string) (time.Time, error)
- 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 Agg
- type Aggs
- type BinaryExpr
- type BooleanLiteral
- type Call
- type DataType
- type Dimension
- type Dimensions
- type ESAgg
- 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 Pos
- type RegexLiteral
- type Scanner
- type SelectStatement
- func (s *SelectStatement) BucketSelectorAggregation() *Agg
- func (s *SelectStatement) ColumnNames() []string
- func (s *SelectStatement) FunctionCalls() []*Call
- func (s *SelectStatement) FunctionCallsByPosition() [][]*Call
- func (s *SelectStatement) HasDerivative() bool
- func (s *SelectStatement) IsSimpleDerivative() bool
- func (s *SelectStatement) NamesInDimension() []string
- func (s *SelectStatement) NamesInHaving() []string
- func (s *SelectStatement) NamesInSelect() []string
- func (s *SelectStatement) NamesInWhere() []string
- func (s *SelectStatement) RewriteConditions()
- func (s *SelectStatement) RewriteDimensions()
- func (s *SelectStatement) RewriteHaving()
- func (s *SelectStatement) String() string
- type SortField
- type SortFields
- type Source
- type Sources
- type Statement
- type Statements
- type StringLiteral
- type Token
- type Valuer
- type VarRef
- type VarRefs
- type Visitor
- type Wildcard
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 )
const ( // MinNanoTime is the minumum time that can be represented. // // 1677-09-21 00:12:43.145224194 +0000 UTC // // The two lowest minimum integers are used as sentinel values. The // minimum value needs to be used as a value lower than any other value for // comparisons and another separate value is needed to act as a sentinel // default value that is unusable by the user, but usable internally. // Because these two values need to be used for a special purpose, we do // not allow users to write points at these two times. MinNanoTime = int64(math.MinInt64) + 2 // MaxNanoTime is the maximum time that can be represented. // // 2262-04-11 23:47:16.854775806 +0000 UTC // // The highest time represented by a nanosecond needs to be used for an // exclusive range in the shard group, so the maximum time needs to be one // less than the possible maximum number of nanoseconds representable by an // int64 so that we don't lose a point at that one time. MaxNanoTime = int64(math.MaxInt64) - 1 // MinTime is used as the minimum time value when computing an unbounded range. // This time is one less than the MinNanoTime so that the first minimum // time can be used as a sentinel value to signify that it is the default // value rather than explicitly set by the user. MinTime = MinNanoTime - 1 // MaxTime is used as the maximum time value when computing an unbounded range. // This time is 2262-04-11 23:47:16.854775806 +0000 UTC MaxTime = MaxNanoTime )
Variables ¶
var ( // ErrInvalidTime is returned when the timestamp string used to // compare against time field is invalid. ErrInvalidTime = errors.New("invalid timestamp string") )
var ( // ErrTimeOutOfRange gets returned when time is out of the representable range using int64 nanoseconds since the epoch. ErrTimeOutOfRange = fmt.Errorf("time outside range %d - %d", MinNanoTime, MaxNanoTime) )
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 GetPrecisionMultiplier ¶
GetPrecisionMultiplier will return a multiplier for the precision specified
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 SafeCalcTime ¶
SafeCalcTime safely calculates the time given. Will return error if the time is outside the supported range.
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 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 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 ESAgg ¶
type ESAgg int
ESAgg enum
const ( IllegalAgg ESAgg = iota //metric aggregations method Avg Cardinality ExtendedStats GeoBounds GeoCentroid Max Min Percentiles PercentileRanks Stats Sum Top ValueCount StarCount // count(*) //bucket aggregations method DateHistogram DateRange Filter Filters GeoDistance GeoHashGrid Global Histogram IPRange Missing Nested Range ReverseNested Sampler SignificantTerms Terms BucketScript BucketSelector )
These are a comprehensive list of es aggregations.
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 (*RegexLiteral) String ¶
func (r *RegexLiteral) String() string
String returns a string representation of the literal.
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.
func (*Scanner) Scan ¶
Scan returns the next token and position from the underlying reader. Also returns the literal text read for strings, numbers, and duration tokens since these token types can have different literal representations.
func (*Scanner) ScanNumber ¶
ScanNumber consumes anything that looks like the start of a number. Numbers start with a digit, full stop, plus sign or minus sign. This function can return non-number tokens if a scan is a false positive. For example, a minus sign followed by a letter will just return a minus sign.
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 // Fields to sort results by SortFields SortFields // Maximum number of rows to be returned. Unlimited if zero. Limit int // Returns rows starting at an offset from the first row. Offset int // Expressions used for grouping the selection. Dimensions Dimensions // Expressions used for filter grouping buckets. Having Expr // if it's a query for raw data values (i.e. not an aggregate) IsRawQuery bool // Removes duplicate rows from raw queries. Dedupe bool }
SelectStatement represents a command for extracting data from the database.
func (*SelectStatement) BucketSelectorAggregation ¶
func (s *SelectStatement) BucketSelectorAggregation() *Agg
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) 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) HasDerivative ¶
func (s *SelectStatement) HasDerivative() bool
HasDerivative returns true if one of the function calls in the statement is a derivative aggregate
func (*SelectStatement) IsSimpleDerivative ¶
func (s *SelectStatement) IsSimpleDerivative() bool
IsSimpleDerivative return true if one of the function call is a derivative function with a variable ref as the first arg
func (*SelectStatement) NamesInDimension ¶
func (s *SelectStatement) NamesInDimension() []string
NamesInDimension returns the field and tag names (idents) in the group by
func (*SelectStatement) NamesInHaving ¶
func (s *SelectStatement) NamesInHaving() []string
NamesInHaving returns the field and tag names (idents) referenced in the having clause
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) RewriteConditions ¶
func (s *SelectStatement) RewriteConditions()
RewriteConditions ...
func (*SelectStatement) RewriteDimensions ¶
func (s *SelectStatement) RewriteDimensions()
RewriteDimensions ...
func (*SelectStatement) String ¶
func (s *SelectStatement) String() string
String returns a string representation of the select statement.
type SortFields ¶
type SortFields []*SortField
SortFields represents an ordered list of ORDER BY fields
func (SortFields) String ¶
func (a SortFields) String() string
String returns a string representation of sort fields
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 and the following are InfluxQL Keywords AS ASC BY DESC FROM GROUP HAVING LIMIT ORDER SELECT WHERE )
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.