Documentation ¶
Overview ¶
Package influxql implements a parser for the InfluxDB query language.
InfluxQL is a DML and DDL language for the InfluxDB time series database. It provides the ability to query for aggregate statistics as well as create and configure the InfluxDB server.
See https://docs.influxdata.com/influxdb/latest/query_language/ for a reference on using InfluxQL.
Index ¶
- Constants
- Variables
- func BinaryExprName(expr *BinaryExpr) string
- func ConditionExpr(cond Expr, valuer Valuer) (Expr, TimeRange, error)
- func ContainsVarRef(expr Expr) bool
- func Eval(expr Expr, m map[string]interface{}) interface{}
- func EvalBool(expr Expr, m map[string]interface{}) bool
- func FieldDimensions(sources Sources, m FieldMapper) (fields map[string]DataType, dimensions map[string]struct{}, err error)
- func FormatDuration(d time.Duration) string
- func HasTimeExpr(expr Expr) bool
- func IdentNeedsQuotes(ident string) bool
- func IsRegexOp(t Token) bool
- func IsSelector(expr Expr) bool
- func IsSystemName(name string) bool
- func ParseDuration(s string) (time.Duration, error)
- func QuoteIdent(segments ...string) string
- func QuoteString(s string) string
- func Sanitize(query 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 AlterRetentionPolicyStatement
- type BinaryExpr
- type BooleanLiteral
- type BooleanValue
- type BoundParameter
- type Call
- type CallTypeMapper
- type CallValuer
- type CreateContinuousQueryStatement
- type CreateDatabaseStatement
- type CreateRetentionPolicyStatement
- type CreateSubscriptionStatement
- type CreateUserStatement
- type DataType
- type DeleteSeriesStatement
- type DeleteStatement
- type Dimension
- type Dimensions
- type Distinct
- type DropContinuousQueryStatement
- type DropDatabaseStatement
- type DropMeasurementStatement
- type DropRetentionPolicyStatement
- type DropSeriesStatement
- type DropShardStatement
- type DropSubscriptionStatement
- type DropUserStatement
- type DurationLiteral
- type DurationValue
- type ErrorValue
- type ExecutionPrivilege
- type ExecutionPrivileges
- type ExplainStatement
- type Expr
- func CloneExpr(expr Expr) Expr
- func ConjunctionsToExprSlice(expr Expr) []Expr
- func ExprsToConjunction(exprs ...Expr) Expr
- func MustParseExpr(s string) Expr
- func ParseExpr(s string) (Expr, error)
- func PartitionExpr(expr Expr, partitionFn func(expression Expr) (bool, error)) (passExpr, failExpr Expr, err error)
- func Reduce(expr Expr, valuer Valuer) Expr
- func RewriteExpr(expr Expr, fn func(Expr) Expr) Expr
- type Field
- type FieldMapper
- type Fields
- type FillOption
- type GrantAdminStatement
- type GrantStatement
- type HasDefaultDatabase
- type Identifier
- type IntegerLiteral
- type IntegerValue
- type KillQueryStatement
- type ListLiteral
- type Literal
- type MapValuer
- type Measurement
- type Measurements
- type NilLiteral
- type Node
- type NowValuer
- type NumberLiteral
- type NumberValue
- type ParenExpr
- type ParseError
- type ParseTree
- type Parser
- func (p *Parser) ParseDuration() (time.Duration, error)
- func (p *Parser) ParseExpr() (Expr, error)
- func (p *Parser) ParseIdent() (string, error)
- func (p *Parser) ParseIdentList() ([]string, error)
- func (p *Parser) ParseInt(min, max int) (int, error)
- func (p *Parser) ParseOptionalTokenAndInt(t Token) (int, error)
- func (p *Parser) ParseQuery() (*Query, error)
- func (p *Parser) ParseStatement() (Statement, error)
- func (p *Parser) ParseUInt64() (uint64, error)
- func (p *Parser) ParseVarRef() (*VarRef, error)
- func (p *Parser) Scan() (tok Token, pos Pos, lit string)
- func (p *Parser) ScanIgnoreWhitespace() (tok Token, pos Pos, lit string)
- func (p *Parser) ScanRegex() (tok Token, pos Pos, lit string)
- func (p *Parser) SetParams(params map[string]interface{})
- func (p *Parser) Unscan()
- type Pos
- type Privilege
- type Query
- type RegexLiteral
- type RegexValue
- type RevokeAdminStatement
- type RevokeStatement
- type Rewriter
- type Scanner
- type SelectStatement
- func (s *SelectStatement) Clone() *SelectStatement
- func (s *SelectStatement) ColumnNames() []string
- func (s *SelectStatement) FieldExprByName(name string) (int, Expr)
- func (s *SelectStatement) GroupByInterval() (time.Duration, error)
- func (s *SelectStatement) GroupByOffset() (time.Duration, error)
- func (s *SelectStatement) HasDimensionWildcard() bool
- func (s *SelectStatement) HasFieldWildcard() (hasWildcard bool)
- func (s *SelectStatement) HasWildcard() bool
- func (s *SelectStatement) Reduce(valuer Valuer) *SelectStatement
- func (s *SelectStatement) RequiredPrivileges() (ExecutionPrivileges, error)
- func (s *SelectStatement) RewriteDistinct()
- func (s *SelectStatement) RewriteFields(m FieldMapper) (*SelectStatement, error)
- func (s *SelectStatement) RewriteRegexConditions()
- func (s *SelectStatement) RewriteTimeFields()
- func (s *SelectStatement) SetTimeRange(start, end time.Time) error
- func (s *SelectStatement) String() string
- func (s *SelectStatement) TimeAscending() bool
- func (s *SelectStatement) TimeFieldName() string
- type SetPasswordUserStatement
- type ShowContinuousQueriesStatement
- type ShowDatabasesStatement
- type ShowDiagnosticsStatement
- type ShowFieldKeyCardinalityStatement
- type ShowFieldKeysStatement
- type ShowGrantsForUserStatement
- type ShowMeasurementCardinalityStatement
- type ShowMeasurementsStatement
- type ShowQueriesStatement
- type ShowRetentionPoliciesStatement
- type ShowSeriesCardinalityStatement
- type ShowSeriesStatement
- type ShowShardGroupsStatement
- type ShowShardsStatement
- type ShowStatsStatement
- type ShowSubscriptionsStatement
- type ShowTagKeyCardinalityStatement
- type ShowTagKeysStatement
- type ShowTagValuesCardinalityStatement
- type ShowTagValuesStatement
- type ShowUsersStatement
- type SortField
- type SortFields
- type Source
- type Sources
- type Statement
- type Statements
- type StringLiteral
- type StringValue
- type SubQuery
- type Target
- type TimeLiteral
- type TimeRange
- type Token
- type TypeError
- type TypeMapper
- type TypeValuerEval
- type UnsignedLiteral
- type Value
- type Valuer
- type ValuerEval
- type VarRef
- type VarRefs
- type Visitor
- type Wildcard
- type ZoneValuer
Constants ¶
const ( // MinTime 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. MinTime = int64(math.MinInt64) + 2 // MaxTime 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. MaxTime = int64(math.MaxInt64) - 1 )
const ( // DateFormat represents the format for date literals. DateFormat = "2006-01-02" // DateTimeFormat represents the format for date time literals. DateTimeFormat = "2006-01-02 15:04:05.999999" )
Variables ¶
var ErrInvalidDuration = errors.New("invalid duration")
ErrInvalidDuration is returned when parsing a malformed duration.
var ( // ErrInvalidTime is returned when the timestamp string used to // compare against time field is invalid. ErrInvalidTime = errors.New("invalid timestamp string") )
var Language = &ParseTree{}
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 ConditionExpr ¶
ConditionExpr extracts the time range and the condition from an expression. We only support simple time ranges that are constrained with AND and are not nested. This throws an error when we encounter a time condition that is combined with OR to prevent returning unexpected results that we do not support.
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 FieldDimensions ¶
func FormatDuration ¶
FormatDuration formats a duration to a string.
func HasTimeExpr ¶
HasTimeExpr returns true if the expression has a time term.
func IdentNeedsQuotes ¶
IdentNeedsQuotes returns true if the ident string given would require quotes.
func IsSelector ¶
func IsSystemName ¶
IsSystemName returns true if name is an internal system name.
func ParseDuration ¶
ParseDuration parses a time duration from a string. This is needed instead of time.ParseDuration because this will support the full syntax that InfluxQL supports for specifying durations including weeks and days.
func QuoteIdent ¶
QuoteIdent returns a quoted identifier from multiple bare identifiers.
func Sanitize ¶
Sanitize attempts to sanitize passwords out of a raw query. It looks for patterns that may be related to the SET PASSWORD and CREATE USER statements and will redact the password that should be there. It will attempt to redact information from common invalid queries too, but it's not guaranteed to succeed on improper queries.
This function works on the raw query and attempts to retain the original input as much as possible.
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 AlterRetentionPolicyStatement ¶
type AlterRetentionPolicyStatement struct { // Name of policy to alter. Name string // Name of the database this policy belongs to. Database string // Duration data written to this policy will be retained. Duration *time.Duration // Replication factor for data written to this policy. Replication *int // Should this policy be set as defalut for the database? Default bool // Duration of the Shard. ShardGroupDuration *time.Duration // Cutoff for future writes FutureWriteLimit *time.Duration // Cutoff for past writes PastWriteLimit *time.Duration }
AlterRetentionPolicyStatement represents a command to alter an existing retention policy.
func (*AlterRetentionPolicyStatement) DefaultDatabase ¶
func (s *AlterRetentionPolicyStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*AlterRetentionPolicyStatement) RequiredPrivileges ¶
func (s *AlterRetentionPolicyStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute an AlterRetentionPolicyStatement.
func (*AlterRetentionPolicyStatement) String ¶
func (s *AlterRetentionPolicyStatement) String() string
String returns a string representation of the alter retention policy statement.
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 BooleanValue ¶ added in v1.1.0
type BooleanValue bool
BooleanValue is a boolean literal.
func (BooleanValue) TokenType ¶ added in v1.1.0
func (v BooleanValue) TokenType() Token
func (BooleanValue) Value ¶ added in v1.1.0
func (v BooleanValue) Value() string
type BoundParameter ¶
type BoundParameter struct {
Name string
}
BoundParameter represents a bound parameter literal. This is not available to the query language itself, but can be used when constructing a query string from an AST.
func (*BoundParameter) String ¶
func (bp *BoundParameter) String() string
String returns a string representation of the bound parameter.
type CallTypeMapper ¶
type CallTypeMapper interface { TypeMapper CallType(name string, args []DataType) (DataType, error) }
CallTypeMapper maps a data type to the function call.
type CallValuer ¶
type CallValuer interface { Valuer // Call is invoked to evaluate a function call (if possible). Call(name string, args []interface{}) (interface{}, bool) }
CallValuer implements the Call method for evaluating function calls.
type CreateContinuousQueryStatement ¶
type CreateContinuousQueryStatement struct { // Name of the continuous query to be created. Name string // Name of the database to create the continuous query on. Database string // Source of data (SELECT statement). Source *SelectStatement // Interval to resample previous queries. ResampleEvery time.Duration // Maximum duration to resample previous queries. ResampleFor time.Duration }
CreateContinuousQueryStatement represents a command for creating a continuous query.
func (*CreateContinuousQueryStatement) DefaultDatabase ¶
func (s *CreateContinuousQueryStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*CreateContinuousQueryStatement) RequiredPrivileges ¶
func (s *CreateContinuousQueryStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a CreateContinuousQueryStatement.
func (*CreateContinuousQueryStatement) String ¶
func (s *CreateContinuousQueryStatement) String() string
String returns a string representation of the statement.
type CreateDatabaseStatement ¶
type CreateDatabaseStatement struct { // Name of the database to be created. Name string // RetentionPolicyCreate indicates whether the user explicitly wants to create a retention policy. RetentionPolicyCreate bool // RetentionPolicyDuration indicates retention duration for the new database. RetentionPolicyDuration *time.Duration // RetentionPolicyReplication indicates retention replication for the new database. RetentionPolicyReplication *int // RetentionPolicyName indicates retention name for the new database. RetentionPolicyName string // RetentionPolicyShardGroupDuration indicates shard group duration for the new database. RetentionPolicyShardGroupDuration time.Duration FutureWriteLimit *time.Duration PastWriteLimit *time.Duration }
CreateDatabaseStatement represents a command for creating a new database.
func (*CreateDatabaseStatement) RequiredPrivileges ¶
func (s *CreateDatabaseStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a CreateDatabaseStatement.
func (*CreateDatabaseStatement) String ¶
func (s *CreateDatabaseStatement) String() string
String returns a string representation of the create database statement.
type CreateRetentionPolicyStatement ¶
type CreateRetentionPolicyStatement struct { // Name of policy to create. Name string // Name of database this policy belongs to. Database string // Duration data written to this policy will be retained. Duration time.Duration // Replication factor for data written to this policy. Replication int // Should this policy be set as default for the database? Default bool // Shard Duration. ShardGroupDuration time.Duration // Error on writes after this duration from now FutureWriteLimit time.Duration // Error on writes before this duration from now PastWriteLimit time.Duration }
CreateRetentionPolicyStatement represents a command to create a retention policy.
func (*CreateRetentionPolicyStatement) DefaultDatabase ¶
func (s *CreateRetentionPolicyStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*CreateRetentionPolicyStatement) RequiredPrivileges ¶
func (s *CreateRetentionPolicyStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a CreateRetentionPolicyStatement.
func (*CreateRetentionPolicyStatement) String ¶
func (s *CreateRetentionPolicyStatement) String() string
String returns a string representation of the create retention policy.
type CreateSubscriptionStatement ¶
type CreateSubscriptionStatement struct { Name string Database string RetentionPolicy string Destinations []string Mode string }
CreateSubscriptionStatement represents a command to add a subscription to the incoming data stream.
func (*CreateSubscriptionStatement) DefaultDatabase ¶
func (s *CreateSubscriptionStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*CreateSubscriptionStatement) RequiredPrivileges ¶
func (s *CreateSubscriptionStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a CreateSubscriptionStatement.
func (*CreateSubscriptionStatement) String ¶
func (s *CreateSubscriptionStatement) String() string
String returns a string representation of the CreateSubscriptionStatement.
type CreateUserStatement ¶
type CreateUserStatement struct { // Name of the user to be created. Name string // User's password. Password string // User's admin privilege. Admin bool }
CreateUserStatement represents a command for creating a new user.
func (*CreateUserStatement) RequiredPrivileges ¶
func (s *CreateUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a CreateUserStatement.
func (*CreateUserStatement) String ¶
func (s *CreateUserStatement) String() string
String returns a string representation of the create user statement.
type DataType ¶
type DataType int
DataType represents the primitive data types available in InfluxQL.
const ( // Unknown primitive data type. Unknown DataType = 0 // Float means the data type is a float. Float DataType = 1 // Integer means the data type is an integer. Integer DataType = 2 // String means the data type is a string of text. String DataType = 3 // Boolean means the data type is a boolean. Boolean DataType = 4 // Time means the data type is a time. Time DataType = 5 // Duration means the data type is a duration of time. Duration DataType = 6 // Tag means the data type is a tag. Tag DataType = 7 // AnyField means the data type is any field. AnyField DataType = 8 // Unsigned means the data type is an unsigned integer. Unsigned DataType = 9 )
func DataTypeFromString ¶
DataTypeFromString returns a data type given the string representation of that data type.
func EvalType ¶
func EvalType(expr Expr, sources Sources, typmap TypeMapper) DataType
EvalType evaluates the expression's type.
func InspectDataType ¶
func InspectDataType(v interface{}) DataType
InspectDataType returns the data type of a given value.
func (DataType) LessThan ¶
LessThan returns true if the other DataType has greater precedence than the current data type. Unknown has the lowest precedence.
NOTE: This is not the same as using the `<` or `>` operator because the integers used decrease with higher precedence, but Unknown is the lowest precedence at the zero value.
type DeleteSeriesStatement ¶
type DeleteSeriesStatement struct { // Data source that fields are extracted from (optional) Sources Sources // An expression evaluated on data point (optional) Condition Expr }
DeleteSeriesStatement represents a command for deleting all or part of a series from a database.
func (DeleteSeriesStatement) RequiredPrivileges ¶
func (s DeleteSeriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a DeleteSeriesStatement.
func (*DeleteSeriesStatement) String ¶
func (s *DeleteSeriesStatement) String() string
String returns a string representation of the delete series statement.
type DeleteStatement ¶
type DeleteStatement struct { // Data source that values are removed from. Source Source // An expression evaluated on data point. Condition Expr }
DeleteStatement represents a command for deleting data from the database.
func (*DeleteStatement) DefaultDatabase ¶
func (s *DeleteStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*DeleteStatement) RequiredPrivileges ¶
func (s *DeleteStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a DeleteStatement.
func (*DeleteStatement) String ¶
func (s *DeleteStatement) String() string
String returns a string representation of the delete statement.
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) Normalize ¶
func (a Dimensions) Normalize() (time.Duration, []string)
Normalize returns the interval and tag dimensions separately. Returns 0 if no time interval is specified.
func (Dimensions) String ¶
func (a Dimensions) String() string
String returns a string representation of the dimensions.
type Distinct ¶
type Distinct struct { // Identifier following DISTINCT Val string }
Distinct represents a DISTINCT expression.
type DropContinuousQueryStatement ¶
DropContinuousQueryStatement represents a command for removing a continuous query.
func (*DropContinuousQueryStatement) DefaultDatabase ¶
func (s *DropContinuousQueryStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*DropContinuousQueryStatement) RequiredPrivileges ¶
func (s *DropContinuousQueryStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a DropContinuousQueryStatement
func (*DropContinuousQueryStatement) String ¶
func (s *DropContinuousQueryStatement) String() string
String returns a string representation of the statement.
type DropDatabaseStatement ¶
type DropDatabaseStatement struct { // Name of the database to be dropped. Name string }
DropDatabaseStatement represents a command to drop a database.
func (*DropDatabaseStatement) RequiredPrivileges ¶
func (s *DropDatabaseStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a DropDatabaseStatement.
func (*DropDatabaseStatement) String ¶
func (s *DropDatabaseStatement) String() string
String returns a string representation of the drop database statement.
type DropMeasurementStatement ¶
type DropMeasurementStatement struct { // Name of the measurement to be dropped. Name string }
DropMeasurementStatement represents a command to drop a measurement.
func (*DropMeasurementStatement) RequiredPrivileges ¶
func (s *DropMeasurementStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a DropMeasurementStatement
func (*DropMeasurementStatement) String ¶
func (s *DropMeasurementStatement) String() string
String returns a string representation of the drop measurement statement.
type DropRetentionPolicyStatement ¶
type DropRetentionPolicyStatement struct { // Name of the policy to drop. Name string // Name of the database to drop the policy from. Database string }
DropRetentionPolicyStatement represents a command to drop a retention policy from a database.
func (*DropRetentionPolicyStatement) DefaultDatabase ¶
func (s *DropRetentionPolicyStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*DropRetentionPolicyStatement) RequiredPrivileges ¶
func (s *DropRetentionPolicyStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a DropRetentionPolicyStatement.
func (*DropRetentionPolicyStatement) String ¶
func (s *DropRetentionPolicyStatement) String() string
String returns a string representation of the drop retention policy statement.
type DropSeriesStatement ¶
type DropSeriesStatement struct { // Data source that fields are extracted from (optional) Sources Sources // An expression evaluated on data point (optional) Condition Expr }
DropSeriesStatement represents a command for removing a series from the database.
func (DropSeriesStatement) RequiredPrivileges ¶
func (s DropSeriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a DropSeriesStatement.
func (*DropSeriesStatement) String ¶
func (s *DropSeriesStatement) String() string
String returns a string representation of the drop series statement.
type DropShardStatement ¶
type DropShardStatement struct { // ID of the shard to be dropped. ID uint64 }
DropShardStatement represents a command for removing a shard from the node.
func (*DropShardStatement) RequiredPrivileges ¶
func (s *DropShardStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a DropShardStatement.
func (*DropShardStatement) String ¶
func (s *DropShardStatement) String() string
String returns a string representation of the drop series statement.
type DropSubscriptionStatement ¶
DropSubscriptionStatement represents a command to drop a subscription to the incoming data stream.
func (*DropSubscriptionStatement) DefaultDatabase ¶
func (s *DropSubscriptionStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*DropSubscriptionStatement) RequiredPrivileges ¶
func (s *DropSubscriptionStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a DropSubscriptionStatement
func (*DropSubscriptionStatement) String ¶
func (s *DropSubscriptionStatement) String() string
String returns a string representation of the DropSubscriptionStatement.
type DropUserStatement ¶
type DropUserStatement struct { // Name of the user to drop. Name string }
DropUserStatement represents a command for dropping a user.
func (*DropUserStatement) RequiredPrivileges ¶
func (s *DropUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a DropUserStatement.
func (*DropUserStatement) String ¶
func (s *DropUserStatement) String() string
String returns a string representation of the drop user statement.
type DurationLiteral ¶
DurationLiteral represents a duration literal.
func (*DurationLiteral) String ¶
func (l *DurationLiteral) String() string
String returns a string representation of the literal.
type DurationValue ¶ added in v1.1.0
type DurationValue string
DurationValue is a duration literal.
func (DurationValue) TokenType ¶ added in v1.1.0
func (v DurationValue) TokenType() Token
func (DurationValue) Value ¶ added in v1.1.0
func (v DurationValue) Value() string
type ErrorValue ¶ added in v1.1.0
type ErrorValue string
ErrorValue is a special value that returns an error during parsing when it is used.
func (ErrorValue) TokenType ¶ added in v1.1.0
func (e ErrorValue) TokenType() Token
func (ErrorValue) Value ¶ added in v1.1.0
func (e ErrorValue) Value() string
type ExecutionPrivilege ¶
type ExecutionPrivilege struct { // Admin privilege required. Admin bool // Name of the database. Name string // Database privilege required. Privilege Privilege }
ExecutionPrivilege is a privilege required for a user to execute a statement on a database or resource.
type ExecutionPrivileges ¶
type ExecutionPrivileges []ExecutionPrivilege
ExecutionPrivileges is a list of privileges required to execute a statement.
type ExplainStatement ¶
type ExplainStatement struct { Statement *SelectStatement Analyze bool Verbose bool }
ExplainStatement represents a command for explaining a select statement.
func (*ExplainStatement) RequiredPrivileges ¶
func (e *ExplainStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ExplainStatement.
func (*ExplainStatement) String ¶
func (e *ExplainStatement) String() string
String returns a string representation of the explain statement.
type Expr ¶
type Expr interface { Node // contains filtered or unexported methods }
Expr represents an expression that can be evaluated to a value.
func ConjunctionsToExprSlice ¶ added in v1.2.0
ConjunctionsToExprSlice finds all children of AndOperators that are not themselves AndOperators, and returns them in a slice. If the root node of expr is not an AndOperator, just returns expr.
AND / \ AND r => {p, q, r} / \ p q
func ExprsToConjunction ¶ added in v1.2.0
ExprsToConjunction accepts a variable number of expressions and ANDs them together into a single expression.
AND / \ {p, q, r} => AND r / \ p q
func MustParseExpr ¶
MustParseExpr parses an expression string and returns its AST. Panic on error.
func PartitionExpr ¶ added in v1.2.0
func PartitionExpr(expr Expr, partitionFn func(expression Expr) (bool, error)) (passExpr, failExpr Expr, err error)
PartitionExpr accepts a predicate expression, separates it into components that have been logically ANDed together, and applies partitionFn to them. Returns two expressions: one AND tree of the expressions for which partitionFn returned true, and an AND tree of expressions for which partitionFn returned false.
Suppose partitonFn returns true for p and r, and false for q:
AND passExpr failExpr / \ AND r => AND q / \ / \ p q p r
type Field ¶
Field represents an expression retrieved from a select statement.
type FieldMapper ¶
type FieldMapper interface { FieldDimensions(m *Measurement) (fields map[string]DataType, dimensions map[string]struct{}, err error) TypeMapper }
FieldMapper returns the data type for the field inside of the measurement.
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 FillOption ¶
type FillOption int
FillOption represents different options for filling aggregate windows.
const ( // NullFill means that empty aggregate windows will just have null values. NullFill FillOption = iota // NoFill means that empty aggregate windows will be purged from the result. NoFill // NumberFill means that empty aggregate windows will be filled with a provided number. NumberFill // PreviousFill means that empty aggregate windows will be filled with whatever the previous aggregate window had. PreviousFill // LinearFill means that empty aggregate windows will be filled with whatever a linear value between non null windows. LinearFill )
type GrantAdminStatement ¶
type GrantAdminStatement struct { // Who to grant the privilege to. User string }
GrantAdminStatement represents a command for granting admin privilege.
func (*GrantAdminStatement) RequiredPrivileges ¶
func (s *GrantAdminStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a GrantAdminStatement.
func (*GrantAdminStatement) String ¶
func (s *GrantAdminStatement) String() string
String returns a string representation of the grant admin statement.
type GrantStatement ¶
type GrantStatement struct { // The privilege to be granted. Privilege Privilege // Database to grant the privilege to. On string // Who to grant the privilege to. User string }
GrantStatement represents a command for granting a privilege.
func (*GrantStatement) DefaultDatabase ¶
func (s *GrantStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*GrantStatement) RequiredPrivileges ¶
func (s *GrantStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a GrantStatement.
func (*GrantStatement) String ¶
func (s *GrantStatement) String() string
String returns a string representation of the grant statement.
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 Identifier ¶ added in v1.1.0
type Identifier string
Identifier is an identifier value.
func (Identifier) TokenType ¶ added in v1.1.0
func (v Identifier) TokenType() Token
func (Identifier) Value ¶ added in v1.1.0
func (v Identifier) Value() string
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 IntegerValue ¶ added in v1.1.0
type IntegerValue int64
IntegerValue is an integer literal.
func (IntegerValue) TokenType ¶ added in v1.1.0
func (v IntegerValue) TokenType() Token
func (IntegerValue) Value ¶ added in v1.1.0
func (v IntegerValue) Value() string
type KillQueryStatement ¶
type KillQueryStatement struct { // The query to kill. QueryID uint64 // The host to delegate the kill to. Host string }
KillQueryStatement represents a command for killing a query.
func (*KillQueryStatement) RequiredPrivileges ¶
func (s *KillQueryStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a KillQueryStatement.
func (*KillQueryStatement) String ¶
func (s *KillQueryStatement) String() string
String returns a string representation of the kill query statement.
type ListLiteral ¶
type ListLiteral struct {
Vals []string
}
ListLiteral represents a list of tag key literals.
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 MapValuer ¶
type MapValuer map[string]interface{}
MapValuer is a valuer that substitutes values for the mapped interface.
type Measurement ¶
type Measurement struct { Database string RetentionPolicy string Name string Regex *RegexLiteral IsTarget bool // This field indicates that the measurement should read be read from the // specified system iterator. SystemIterator string }
Measurement represents a single measurement used as a datasource.
func (*Measurement) Clone ¶
func (m *Measurement) Clone() *Measurement
Clone returns a deep clone of the Measurement.
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 NilLiteral ¶
type NilLiteral struct{}
NilLiteral represents a nil literal. This is not available to the query language itself. It's only used internally.
func (*NilLiteral) String ¶
func (l *NilLiteral) String() string
String returns a string representation of the literal.
type Node ¶
type Node interface { String() string // contains filtered or unexported methods }
Node represents a node in the InfluxDB abstract syntax tree.
type NowValuer ¶
NowValuer returns only the value for "now()".
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 NumberValue ¶ added in v1.1.0
type NumberValue float64
NumberValue is a number literal.
func (NumberValue) TokenType ¶ added in v1.1.0
func (v NumberValue) TokenType() Token
func (NumberValue) Value ¶ added in v1.1.0
func (v NumberValue) Value() string
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 ParseTree ¶
type ParseTree struct { Handlers map[Token]func(*Parser) (Statement, error) Tokens map[Token]*ParseTree Keys []string }
func (*ParseTree) Group ¶
Group groups together a set of related handlers with a common token prefix.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser represents an InfluxQL parser.
func (*Parser) ParseDuration ¶
ParseDuration parses a string and returns a duration literal. This function assumes the DURATION token has already been consumed.
func (*Parser) ParseIdent ¶
ParseIdent parses an identifier.
func (*Parser) ParseIdentList ¶
ParseIdentList parses a comma delimited list of identifiers.
func (*Parser) ParseInt ¶
ParseInt parses a string representing a base 10 integer and returns the number. It returns an error if the parsed number is outside the range [min, max].
func (*Parser) ParseOptionalTokenAndInt ¶
ParseOptionalTokenAndInt parses the specified token followed by an int, if it exists.
func (*Parser) ParseQuery ¶
ParseQuery parses an InfluxQL string and returns a Query AST object.
func (*Parser) ParseStatement ¶
ParseStatement parses an InfluxQL string and returns a Statement AST object.
func (*Parser) ParseUInt64 ¶
ParseUInt64 parses a string and returns a 64-bit unsigned integer literal.
func (*Parser) ParseVarRef ¶
ParseVarRef parses a reference to a measurement or field.
func (*Parser) ScanIgnoreWhitespace ¶
ScanIgnoreWhitespace scans the next non-whitespace and non-comment token.
func (*Parser) ScanRegex ¶ added in v1.1.0
ScanRegex returns the next token from the underlying scanner using the regex scanner.
type Pos ¶
Pos specifies the line and character position of a token. The Char and Line are both zero-based indexes.
type Privilege ¶
type Privilege int
Privilege is a type of action a user can be granted the right to use.
const ( // NoPrivileges means no privileges required / granted / revoked. NoPrivileges Privilege = iota // ReadPrivilege means read privilege required / granted / revoked. ReadPrivilege // WritePrivilege means write privilege required / granted / revoked. WritePrivilege // AllPrivileges means all privileges required / granted / revoked. AllPrivileges )
func NewPrivilege ¶
NewPrivilege returns an initialized *Privilege.
type Query ¶
type Query struct {
Statements Statements
}
Query represents a collection of ordered statements.
func ParseQuery ¶
ParseQuery parses a query string and returns its AST representation.
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 RegexValue ¶ added in v1.1.0
type RegexValue string
RegexValue is a regexp literal.
func (RegexValue) TokenType ¶ added in v1.1.0
func (v RegexValue) TokenType() Token
func (RegexValue) Value ¶ added in v1.1.0
func (v RegexValue) Value() string
type RevokeAdminStatement ¶
type RevokeAdminStatement struct { // Who to revoke admin privilege from. User string }
RevokeAdminStatement represents a command to revoke admin privilege from a user.
func (*RevokeAdminStatement) RequiredPrivileges ¶
func (s *RevokeAdminStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a RevokeAdminStatement.
func (*RevokeAdminStatement) String ¶
func (s *RevokeAdminStatement) String() string
String returns a string representation of the revoke admin statement.
type RevokeStatement ¶
type RevokeStatement struct { // The privilege to be revoked. Privilege Privilege // Database to revoke the privilege from. On string // Who to revoke privilege from. User string }
RevokeStatement represents a command to revoke a privilege from a user.
func (*RevokeStatement) DefaultDatabase ¶
func (s *RevokeStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*RevokeStatement) RequiredPrivileges ¶
func (s *RevokeStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a RevokeStatement.
func (*RevokeStatement) String ¶
func (s *RevokeStatement) String() string
String returns a string representation of the revoke statement.
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 // Target (destination) for the result of a SELECT INTO query. Target *Target // Expressions used for grouping the selection. Dimensions Dimensions // Data sources (measurements) 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 // Maxiumum number of series to be returned. Unlimited if zero. SLimit int // Returns series starting at an offset from the first one. SOffset int // Whether it's a query for raw data values (i.e. not an aggregate). IsRawQuery bool // What fill option the select statement uses, if any. Fill FillOption // The value to fill empty aggregate buckets with, if any. FillValue interface{} // The timezone for the query, if any. Location *time.Location // Renames the implicit time field name. TimeAlias string // Removes the "time" column from the output. OmitTime bool // Removes measurement name from resulting query. Useful for meta queries. StripName bool // Overrides the output measurement name. EmitName string // Removes duplicate rows from raw queries. Dedupe bool // contains filtered or unexported fields }
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) FieldExprByName ¶
func (s *SelectStatement) FieldExprByName(name string) (int, Expr)
FieldExprByName returns the expression that matches the field name and the index where this was found. If the name matches one of the arguments to "top" or "bottom", the variable reference inside of the function is returned and the index is of the function call rather than the variable reference. If no expression is found, -1 is returned for the index and the expression will be nil.
func (*SelectStatement) GroupByInterval ¶
func (s *SelectStatement) GroupByInterval() (time.Duration, error)
GroupByInterval extracts the time interval, if specified.
func (*SelectStatement) GroupByOffset ¶
func (s *SelectStatement) GroupByOffset() (time.Duration, error)
GroupByOffset extracts the time interval offset, if specified.
func (*SelectStatement) HasDimensionWildcard ¶
func (s *SelectStatement) HasDimensionWildcard() bool
HasDimensionWildcard returns whether or not the select statement has at least 1 wildcard in the dimensions aka `GROUP BY`.
func (*SelectStatement) HasFieldWildcard ¶
func (s *SelectStatement) HasFieldWildcard() (hasWildcard bool)
HasFieldWildcard returns whether or not the select statement has at least 1 wildcard in the fields.
func (*SelectStatement) HasWildcard ¶
func (s *SelectStatement) HasWildcard() bool
HasWildcard returns whether or not the select statement has at least 1 wildcard.
func (*SelectStatement) Reduce ¶
func (s *SelectStatement) Reduce(valuer Valuer) *SelectStatement
Reduce calls the Reduce function on the different components of the SelectStatement to reduce the statement.
func (*SelectStatement) RequiredPrivileges ¶
func (s *SelectStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute the SelectStatement. NOTE: Statement should be normalized first (database name(s) in Sources and Target should be populated). If the statement has not been normalized, an empty string will be returned for the database name and it is up to the caller to interpret that as the default database.
func (*SelectStatement) RewriteDistinct ¶
func (s *SelectStatement) RewriteDistinct()
RewriteDistinct rewrites the expression to be a call for map/reduce to work correctly. This method assumes all validation has passed.
func (*SelectStatement) RewriteFields ¶
func (s *SelectStatement) RewriteFields(m FieldMapper) (*SelectStatement, error)
RewriteFields returns the re-written form of the select statement. Any wildcard query fields are replaced with the supplied fields, and any wildcard GROUP BY fields are replaced with the supplied dimensions. Any fields with no type specifier are rewritten with the appropriate type.
func (*SelectStatement) RewriteRegexConditions ¶
func (s *SelectStatement) RewriteRegexConditions()
RewriteRegexConditions rewrites regex conditions to make better use of the database index.
Conditions that can currently be simplified are:
- host =~ /^foo$/ becomes host = 'foo'
- host !~ /^foo$/ becomes host != 'foo'
Note: if the regex contains groups, character classes, repetition or similar, it's likely it won't be rewritten. In order to support rewriting regexes with these characters would be a lot more work.
func (*SelectStatement) RewriteTimeFields ¶
func (s *SelectStatement) RewriteTimeFields()
RewriteTimeFields removes any "time" field references.
func (*SelectStatement) SetTimeRange ¶
func (s *SelectStatement) SetTimeRange(start, end time.Time) error
SetTimeRange sets the start and end time of the select statement to [start, end). i.e. start inclusive, end exclusive. This is used commonly for continuous queries so the start and end are in buckets.
func (*SelectStatement) String ¶
func (s *SelectStatement) String() string
String returns a string representation of the select statement.
func (*SelectStatement) TimeAscending ¶
func (s *SelectStatement) TimeAscending() bool
TimeAscending returns true if the time field is sorted in chronological order.
func (*SelectStatement) TimeFieldName ¶
func (s *SelectStatement) TimeFieldName() string
TimeFieldName returns the name of the time field.
type SetPasswordUserStatement ¶
type SetPasswordUserStatement struct { // Plain-text password. Password string // Who to grant the privilege to. Name string }
SetPasswordUserStatement represents a command for changing user password.
func (*SetPasswordUserStatement) RequiredPrivileges ¶
func (s *SetPasswordUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a SetPasswordUserStatement.
func (*SetPasswordUserStatement) String ¶
func (s *SetPasswordUserStatement) String() string
String returns a string representation of the set password statement.
type ShowContinuousQueriesStatement ¶
type ShowContinuousQueriesStatement struct{}
ShowContinuousQueriesStatement represents a command for listing continuous queries.
func (*ShowContinuousQueriesStatement) RequiredPrivileges ¶
func (s *ShowContinuousQueriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowContinuousQueriesStatement.
func (*ShowContinuousQueriesStatement) String ¶
func (s *ShowContinuousQueriesStatement) String() string
String returns a string representation of the show continuous queries statement.
type ShowDatabasesStatement ¶
type ShowDatabasesStatement struct{}
ShowDatabasesStatement represents a command for listing all databases in the cluster.
func (*ShowDatabasesStatement) RequiredPrivileges ¶
func (s *ShowDatabasesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowDatabasesStatement.
func (*ShowDatabasesStatement) String ¶
func (s *ShowDatabasesStatement) String() string
String returns a string representation of the show databases command.
type ShowDiagnosticsStatement ¶
type ShowDiagnosticsStatement struct { // Module Module string }
ShowDiagnosticsStatement represents a command for show node diagnostics.
func (*ShowDiagnosticsStatement) RequiredPrivileges ¶
func (s *ShowDiagnosticsStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowDiagnosticsStatement
func (*ShowDiagnosticsStatement) String ¶
func (s *ShowDiagnosticsStatement) String() string
String returns a string representation of the ShowDiagnosticsStatement.
type ShowFieldKeyCardinalityStatement ¶
type ShowFieldKeyCardinalityStatement struct { Database string Exact bool Sources Sources Condition Expr Dimensions Dimensions Limit, Offset int }
ShowFieldKeyCardinalityStatement represents a command for listing field key cardinality.
func (*ShowFieldKeyCardinalityStatement) DefaultDatabase ¶
func (s *ShowFieldKeyCardinalityStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowFieldKeyCardinalityStatement) RequiredPrivileges ¶
func (s *ShowFieldKeyCardinalityStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowFieldKeyCardinalityStatement.
func (*ShowFieldKeyCardinalityStatement) String ¶
func (s *ShowFieldKeyCardinalityStatement) String() string
String returns a string representation of the statement.
type ShowFieldKeysStatement ¶
type ShowFieldKeysStatement struct { // Database to query. If blank, use the default database. // The database can also be specified per source in the Sources. Database string // Data sources that fields are extracted from. Sources Sources // 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 }
ShowFieldKeysStatement represents a command for listing field keys.
func (*ShowFieldKeysStatement) DefaultDatabase ¶
func (s *ShowFieldKeysStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowFieldKeysStatement) RequiredPrivileges ¶
func (s *ShowFieldKeysStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a ShowFieldKeysStatement.
func (*ShowFieldKeysStatement) String ¶
func (s *ShowFieldKeysStatement) String() string
String returns a string representation of the statement.
type ShowGrantsForUserStatement ¶
type ShowGrantsForUserStatement struct { // Name of the user to display privileges. Name string }
ShowGrantsForUserStatement represents a command for listing user privileges.
func (*ShowGrantsForUserStatement) RequiredPrivileges ¶
func (s *ShowGrantsForUserStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowGrantsForUserStatement
func (*ShowGrantsForUserStatement) String ¶
func (s *ShowGrantsForUserStatement) String() string
String returns a string representation of the show grants for user.
type ShowMeasurementCardinalityStatement ¶
type ShowMeasurementCardinalityStatement struct { Exact bool // If false then cardinality estimation will be used. Database string Sources Sources Condition Expr Dimensions Dimensions Limit, Offset int }
ShowMeasurementCardinalityStatement represents a command for listing measurement cardinality.
func (*ShowMeasurementCardinalityStatement) DefaultDatabase ¶
func (s *ShowMeasurementCardinalityStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowMeasurementCardinalityStatement) RequiredPrivileges ¶
func (s *ShowMeasurementCardinalityStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowMeasurementCardinalityStatement.
func (*ShowMeasurementCardinalityStatement) String ¶
func (s *ShowMeasurementCardinalityStatement) String() string
String returns a string representation of the statement.
type ShowMeasurementsStatement ¶
type ShowMeasurementsStatement struct { // Database to query. If blank, use the default database. Database string // Retention policy to query. If blank, use all retention policies (do not use default) RetentionPolicy string WildcardDatabase bool WildcardRetentionPolicy bool // Measurement name or regex. Source Source // 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 }
ShowMeasurementsStatement represents a command for listing measurements.
func (*ShowMeasurementsStatement) DefaultDatabase ¶
func (s *ShowMeasurementsStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowMeasurementsStatement) RequiredPrivileges ¶
func (s *ShowMeasurementsStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a ShowMeasurementsStatement.
func (*ShowMeasurementsStatement) String ¶
func (s *ShowMeasurementsStatement) String() string
String returns a string representation of the statement.
type ShowQueriesStatement ¶
type ShowQueriesStatement struct{}
ShowQueriesStatement represents a command for listing all running queries.
func (*ShowQueriesStatement) RequiredPrivileges ¶
func (s *ShowQueriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowQueriesStatement.
func (*ShowQueriesStatement) String ¶
func (s *ShowQueriesStatement) String() string
String returns a string representation of the show queries statement.
type ShowRetentionPoliciesStatement ¶
type ShowRetentionPoliciesStatement struct { // Name of the database to list policies for. Database string }
ShowRetentionPoliciesStatement represents a command for listing retention policies.
func (*ShowRetentionPoliciesStatement) DefaultDatabase ¶
func (s *ShowRetentionPoliciesStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowRetentionPoliciesStatement) RequiredPrivileges ¶
func (s *ShowRetentionPoliciesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a ShowRetentionPoliciesStatement
func (*ShowRetentionPoliciesStatement) String ¶
func (s *ShowRetentionPoliciesStatement) String() string
String returns a string representation of a ShowRetentionPoliciesStatement.
type ShowSeriesCardinalityStatement ¶
type ShowSeriesCardinalityStatement struct { // Database to query. If blank, use the default database. // The database can also be specified per source in the Sources. Database string // Specifies whether the user requires exact counting or not. Exact bool // Measurement(s) the series are listed for. Sources Sources // An expression evaluated on a series name or tag. Condition Expr // Expressions used for grouping the selection. Dimensions Dimensions Limit, Offset int }
ShowSeriesCardinalityStatement represents a command for listing series cardinality.
func (*ShowSeriesCardinalityStatement) DefaultDatabase ¶
func (s *ShowSeriesCardinalityStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowSeriesCardinalityStatement) RequiredPrivileges ¶
func (s *ShowSeriesCardinalityStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowSeriesCardinalityStatement.
func (*ShowSeriesCardinalityStatement) String ¶
func (s *ShowSeriesCardinalityStatement) String() string
String returns a string representation of the show continuous queries statement.
type ShowSeriesStatement ¶
type ShowSeriesStatement struct { // Database to query. If blank, use the default database. // The database can also be specified per source in the Sources. Database string // Measurement(s) the series are listed for. Sources Sources // An expression evaluated on a series name or tag. 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 }
ShowSeriesStatement represents a command for listing series in the database.
func (*ShowSeriesStatement) DefaultDatabase ¶
func (s *ShowSeriesStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowSeriesStatement) RequiredPrivileges ¶
func (s *ShowSeriesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowSeriesStatement.
func (*ShowSeriesStatement) String ¶
func (s *ShowSeriesStatement) String() string
String returns a string representation of the list series statement.
type ShowShardGroupsStatement ¶
type ShowShardGroupsStatement struct{}
ShowShardGroupsStatement represents a command for displaying shard groups in the cluster.
func (*ShowShardGroupsStatement) RequiredPrivileges ¶
func (s *ShowShardGroupsStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privileges required to execute the statement.
func (*ShowShardGroupsStatement) String ¶
func (s *ShowShardGroupsStatement) String() string
String returns a string representation of the SHOW SHARD GROUPS command.
type ShowShardsStatement ¶
type ShowShardsStatement struct{}
ShowShardsStatement represents a command for displaying shards in the cluster.
func (*ShowShardsStatement) RequiredPrivileges ¶
func (s *ShowShardsStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privileges required to execute the statement.
func (*ShowShardsStatement) String ¶
func (s *ShowShardsStatement) String() string
String returns a string representation.
type ShowStatsStatement ¶
type ShowStatsStatement struct {
Module string
}
ShowStatsStatement displays statistics for a given module.
func (*ShowStatsStatement) RequiredPrivileges ¶
func (s *ShowStatsStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a ShowStatsStatement
func (*ShowStatsStatement) String ¶
func (s *ShowStatsStatement) String() string
String returns a string representation of a ShowStatsStatement.
type ShowSubscriptionsStatement ¶
type ShowSubscriptionsStatement struct { }
ShowSubscriptionsStatement represents a command to show a list of subscriptions.
func (*ShowSubscriptionsStatement) RequiredPrivileges ¶
func (s *ShowSubscriptionsStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowSubscriptionsStatement.
func (*ShowSubscriptionsStatement) String ¶
func (s *ShowSubscriptionsStatement) String() string
String returns a string representation of the ShowSubscriptionsStatement.
type ShowTagKeyCardinalityStatement ¶
type ShowTagKeyCardinalityStatement struct { Database string Exact bool Sources Sources Condition Expr Dimensions Dimensions Limit, Offset int }
ShowTagKeyCardinalityStatement represents a command for listing tag key cardinality.
func (*ShowTagKeyCardinalityStatement) DefaultDatabase ¶
func (s *ShowTagKeyCardinalityStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowTagKeyCardinalityStatement) RequiredPrivileges ¶
func (s *ShowTagKeyCardinalityStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowTagKeyCardinalityStatement.
func (*ShowTagKeyCardinalityStatement) String ¶
func (s *ShowTagKeyCardinalityStatement) String() string
String returns a string representation of the statement.
type ShowTagKeysStatement ¶
type ShowTagKeysStatement struct { // Database to query. If blank, use the default database. // The database can also be specified per source in the Sources. Database string // Data sources that fields are extracted from. Sources Sources // Op to compare tag keys with TagKeyOp Token // Literal to compare tag keys with TagKeyExpr Expr // An expression evaluated on data point. Condition Expr // Fields to sort results by. SortFields SortFields // Maximum number of tag keys per measurement. Unlimited if zero. Limit int // Returns tag keys starting at an offset from the first row. Offset int // Maxiumum number of series to be returned. Unlimited if zero. SLimit int // Returns series starting at an offset from the first one. SOffset int }
ShowTagKeysStatement represents a command for listing tag keys.
func (*ShowTagKeysStatement) DefaultDatabase ¶
func (s *ShowTagKeysStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowTagKeysStatement) RequiredPrivileges ¶
func (s *ShowTagKeysStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a ShowTagKeysStatement.
func (*ShowTagKeysStatement) String ¶
func (s *ShowTagKeysStatement) String() string
String returns a string representation of the statement.
type ShowTagValuesCardinalityStatement ¶
type ShowTagValuesCardinalityStatement struct { Database string Exact bool Sources Sources Op Token TagKeyExpr Literal Condition Expr Dimensions Dimensions Limit, Offset int }
ShowTagValuesCardinalityStatement represents a command for listing tag value cardinality.
func (*ShowTagValuesCardinalityStatement) DefaultDatabase ¶
func (s *ShowTagValuesCardinalityStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowTagValuesCardinalityStatement) RequiredPrivileges ¶
func (s *ShowTagValuesCardinalityStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege required to execute a ShowTagValuesCardinalityStatement.
func (*ShowTagValuesCardinalityStatement) String ¶
func (s *ShowTagValuesCardinalityStatement) String() string
String returns a string representation of the statement.
type ShowTagValuesStatement ¶
type ShowTagValuesStatement struct { // Database to query. If blank, use the default database. // The database can also be specified per source in the Sources. Database string // Data source that fields are extracted from. Sources Sources // Operation to use when selecting tag key(s). // This is one of: (associated TagKeyExpr Literal // type in parentheses: // EQ (*StringLiteral) // NEQ (*StringLiteral) // IN (*ListLiteral) // EQREGEX (*RegexLiteral) // NEQREGEX (*RegexLiteral) Op Token // Literal to compare the tag key(s) with. // The value of the above Op field determines its dynamic type. TagKeyExpr Literal // An expression evaluated on each data point. Condition Expr // NOTE: The specfication doesn't permit ORDER BY in // a SHOW TAG VALUES statement and this field is // ignored in practice. It's only left here to maintain // backward compatibility. 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 }
ShowTagValuesStatement represents a command for listing tag values.
func (*ShowTagValuesStatement) DefaultDatabase ¶
func (s *ShowTagValuesStatement) DefaultDatabase() string
DefaultDatabase returns the default database from the statement.
func (*ShowTagValuesStatement) RequiredPrivileges ¶
func (s *ShowTagValuesStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a ShowTagValuesStatement.
func (*ShowTagValuesStatement) String ¶
func (s *ShowTagValuesStatement) String() string
String returns a string representation of the statement.
type ShowUsersStatement ¶
type ShowUsersStatement struct{}
ShowUsersStatement represents a command for listing users.
func (*ShowUsersStatement) RequiredPrivileges ¶
func (s *ShowUsersStatement) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges returns the privilege(s) required to execute a ShowUsersStatement
func (*ShowUsersStatement) String ¶
func (s *ShowUsersStatement) String() string
String returns a string representation of the ShowUsersStatement.
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 Sources ¶
type Sources []Source
Sources represents a list of sources.
func (Sources) MarshalBinary ¶
MarshalBinary encodes a list of sources to a binary format.
func (Sources) Measurements ¶
func (a Sources) Measurements() []*Measurement
Measurements returns all measurements including ones embedded in subqueries.
func (Sources) RequiredPrivileges ¶
func (a Sources) RequiredPrivileges() (ExecutionPrivileges, error)
RequiredPrivileges recursively returns a list of execution privileges required.
func (*Sources) UnmarshalBinary ¶
UnmarshalBinary decodes binary data into a list of sources.
type Statement ¶
type Statement interface { Node RequiredPrivileges() (ExecutionPrivileges, error) // contains filtered or unexported methods }
Statement represents a single command in InfluxQL.
func MustParseStatement ¶
MustParseStatement parses a statement string and returns its AST. Panic on error.
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) IsTimeLiteral ¶
func (l *StringLiteral) IsTimeLiteral() bool
IsTimeLiteral returns if this string can be interpreted as a time literal.
func (*StringLiteral) String ¶
func (l *StringLiteral) String() string
String returns a string representation of the literal.
func (*StringLiteral) ToTimeLiteral ¶
func (l *StringLiteral) ToTimeLiteral(loc *time.Location) (*TimeLiteral, error)
ToTimeLiteral returns a time literal if this string can be converted to a time literal.
type StringValue ¶ added in v1.1.0
type StringValue string
StringValue is a string literal.
func (StringValue) TokenType ¶ added in v1.1.0
func (v StringValue) TokenType() Token
func (StringValue) Value ¶ added in v1.1.0
func (v StringValue) Value() string
type SubQuery ¶
type SubQuery struct {
Statement *SelectStatement
}
SubQuery is a source with a SelectStatement as the backing store.
type Target ¶
type Target struct { // Measurement to write into. Measurement *Measurement }
Target represents a target (destination) policy, measurement, and DB.
type TimeLiteral ¶
TimeLiteral represents a point-in-time literal.
func (*TimeLiteral) String ¶
func (l *TimeLiteral) String() string
String returns a string representation of the literal.
type TimeRange ¶
TimeRange represents a range of time from Min to Max. The times are inclusive.
func (TimeRange) MaxTime ¶
MaxTime returns the maximum time of the TimeRange. If the maximum time is zero, this returns the maximum possible time.
func (TimeRange) MaxTimeNano ¶
MaxTimeNano returns the maximum time in nanoseconds since the epoch. If the maximum time is zero, this returns the maximum possible time.
func (TimeRange) MinTime ¶
MinTime returns the minimum time of the TimeRange. If the minimum time is zero, this returns the minimum possible time.
func (TimeRange) MinTimeNano ¶
MinTimeNano returns the minimum time in nanoseconds since the epoch. If the minimum time is zero, this returns the minimum possible time.
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 COMMENT // IDENT and the following are InfluxQL literal tokens. IDENT // main BOUNDPARAM // $param NUMBER // 12345.67 INTEGER // 12345 DURATIONVAL // 13h 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 // % BITWISE_AND // & BITWISE_OR // | BITWISE_XOR // ^ AND // AND OR // OR EQ // = NEQ // != EQREGEX // =~ NEQREGEX // !~ LT // < LTE // <= GT // > GTE // >= LPAREN // ( RPAREN // ) COMMA // , COLON // : DOUBLECOLON // :: SEMICOLON // ; DOT // . // ALL and the following are InfluxQL Keywords ALL ALTER ANALYZE ANY AS ASC BEGIN BY CARDINALITY CREATE CONTINUOUS DATABASE DATABASES DEFAULT DELETE DESC DESTINATIONS DIAGNOSTICS DISTINCT DROP DURATION END EVERY EXACT EXPLAIN FIELD FOR FROM FUTURE GRANT GRANTS GROUP GROUPS IN INF INSERT INTO KEY KEYS KILL LIMIT MEASUREMENT MEASUREMENTS NAME OFFSET ON ORDER PASSWORD PAST POLICY POLICIES PRIVILEGES QUERIES QUERY READ REPLICATION RESAMPLE RETENTION REVOKE SELECT SERIES SET SHOW SHARD SHARDS SLIMIT SOFFSET STATS SUBSCRIPTION SUBSCRIPTIONS TAG TO USER USERS VALUES VERBOSE WHERE WITH WRITE )
These are a comprehensive list of InfluxQL language tokens.
func (Token) Precedence ¶
Precedence returns the operator precedence of the binary operator token.
type TypeError ¶
type TypeError struct { // Expr contains the expression that generated the type error. Expr Expr // Message contains the informational message about the type error. Message string }
TypeError is an error when two types are incompatible.
type TypeMapper ¶
type TypeMapper interface {
MapType(measurement *Measurement, field string) DataType
}
TypeMapper maps a data type to the measurement and field.
func MultiTypeMapper ¶
func MultiTypeMapper(mappers ...TypeMapper) TypeMapper
MultiTypeMapper combines multiple TypeMappers into a single one. The MultiTypeMapper will return the first type that is not Unknown. It will not iterate through all of them to find the highest priority one.
type TypeValuerEval ¶
type TypeValuerEval struct { TypeMapper TypeMapper Sources Sources }
TypeValuerEval evaluates an expression to determine its output type.
func (*TypeValuerEval) EvalType ¶
func (v *TypeValuerEval) EvalType(expr Expr) (DataType, error)
EvalType returns the type for an expression. If the expression cannot be evaluated for some reason, like incompatible types, it is returned as a TypeError in the error. If the error is non-fatal so we can continue even though an error happened, true will be returned. This function assumes that the expression has already been reduced.
type UnsignedLiteral ¶
type UnsignedLiteral struct {
Val uint64
}
UnsignedLiteral represents an unsigned literal. The parser will only use an unsigned literal if the parsed integer is greater than math.MaxInt64.
func (*UnsignedLiteral) String ¶
func (l *UnsignedLiteral) String() string
String returns a string representation of the literal.
type Value ¶ added in v1.1.0
Value represents a value that can be bound to a parameter when parsing the query.
type Valuer ¶
type Valuer interface { // Value returns the value and existence flag for a given key. Value(key string) (interface{}, bool) }
Valuer is the interface that wraps the Value() method.
func MultiValuer ¶
MultiValuer returns a Valuer that iterates over multiple Valuer instances to find a match.
type ValuerEval ¶
type ValuerEval struct { Valuer Valuer // IntegerFloatDivision will set the eval system to treat // a division between two integers as a floating point division. IntegerFloatDivision bool }
ValuerEval will evaluate an expression using the Valuer.
func (*ValuerEval) Eval ¶
func (v *ValuerEval) Eval(expr Expr) interface{}
Eval evaluates an expression and returns a value.
func (*ValuerEval) EvalBool ¶
func (v *ValuerEval) EvalBool(expr Expr) bool
EvalBool evaluates expr and returns true if result is a boolean true. Otherwise returns false.
type VarRef ¶
VarRef represents a reference to a variable.
type VarRefs ¶
type VarRefs []VarRef
VarRefs represents a slice of VarRef types.
type Visitor ¶
Visitor can be called by Walk to traverse an AST hierarchy. The Visit() function is called once per node.
type ZoneValuer ¶
type ZoneValuer interface { Valuer // Zone returns the time zone location. This function may return nil // if no time zone is known. Zone() *time.Location }
ZoneValuer is the interface that specifies the current time zone.