sql

package
v0.0.0-...-4471eec Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2015 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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
	// Boolean means the data type is a boolean.
	Boolean = 3
	// String means the data type is a string of text.
	String = 4
	// Time means the data type is a time.
	Time = 5
	// Duration means the data type is a duration of time.
	Duration = 6
)
View Source
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

View Source
var ErrInvalidDuration = errors.New("invalid duration")

ErrInvalidDuration is returned when parsing a malformatted duration.

Functions

func Eval

func Eval(expr Expr, m map[string]interface{}) interface{}

Eval evaluates expr against a map.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration to a string.

func IdentNeedsQuotes

func IdentNeedsQuotes(ident string) bool

IdentNeedsQuotes returns true if the ident string given would require quotes.

func IsRegexOp

func IsRegexOp(t Token) bool

IsRegexOp returns true if the operator accepts a regex operand.

func MapCount

func MapCount(itr Iterator) interface{}

MapCount computes the number of values in an iterator.

func MapRawQuery

func MapRawQuery(itr Iterator) interface{}

MapRawQuery is for queries without aggregates

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a time duration from a string.

func QuoteIdent

func QuoteIdent(segments ...string) string

QuoteIdent returns a quoted identifier from multiple bare identifiers.

func QuoteString

func QuoteString(s string) string

QuoteString returns a quoted string.

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)

func ScanString

func ScanString(r io.RuneScanner) (string, error)

ScanString reads a quoted string from a rune reader.

func TimeRange

func TimeRange(expr Expr) (min, max time.Time)

TimeRange returns the minimum and maximum times specified by an expression. Returns zero times if there is no bound.

func TimeRangeAsEpochNano

func TimeRangeAsEpochNano(expr Expr) (min, max int64)

TimeRangeAsEpochNano returns the minimum and maximum times, as epoch nano, specified by and expression. If there is no lower bound, the start of the epoch is returned for minimum. If there is no higher bound, now is returned for maximum.

func Walk

func Walk(v Visitor, node Node)

Walk traverses a node hierarchy in depth-first order.

func WalkFunc

func WalkFunc(node Node, fn func(Node))

WalkFunc traverses a node hierarchy in depth-first order.

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
}

AlterRetentionPolicyStatement represents a command to alter an existing retention policy.

func (*AlterRetentionPolicyStatement) RequiredPrivileges

func (s *AlterRetentionPolicyStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute an AlterRetentionPolicyStatement.

func (*AlterRetentionPolicyStatement) String

String returns a string representation of the alter retention policy statement.

type BinaryExpr

type BinaryExpr struct {
	Op  Token
	LHS Expr
	RHS Expr
}

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
}

Call represents a function call.

func (*Call) String

func (c *Call) String() string

String returns a string representation of the call.

type Conversation

type Conversation struct {
	Database        string
	RetentionPolicy string
	Name            string
	Regex           *RegexLiteral
}

Conversation represents a single conversation used as a datasource.

func (*Conversation) String

func (m *Conversation) String() string

String returns a string representation of the conversation.

type Conversations

type Conversations []*Conversation

Conversations represents a list of conversations.

func (Conversations) String

func (a Conversations) String() string

String returns a string representation of the conversations.

type CreateDatabaseStatement

type CreateDatabaseStatement struct {
	// Name of the database to be created.
	Name string
}

CreateDatabaseStatement represents a command for creating a new database.

func (*CreateDatabaseStatement) RequiredPrivileges

func (s *CreateDatabaseStatement) RequiredPrivileges() ExecutionPrivileges

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
}

CreateRetentionPolicyStatement represents a command to create a retention policy.

func (*CreateRetentionPolicyStatement) RequiredPrivileges

func (s *CreateRetentionPolicyStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a CreateRetentionPolicyStatement.

func (*CreateRetentionPolicyStatement) String

String returns a string representation of the create retention policy.

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

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 MessageQL.

func InspectDataType

func InspectDataType(v interface{}) DataType

InspectDataType returns the data type of a given value.

func (DataType) String

func (d DataType) String() string

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 removing data from the database.

func (*DeleteStatement) RequiredPrivileges

func (s *DeleteStatement) RequiredPrivileges() ExecutionPrivileges

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.

func (*Dimension) String

func (d *Dimension) String() string

String returns a string representation of the dimension.

type Dimensions

type Dimensions []*Dimension

Dimensions represents a list of dimensions.

func (Dimensions) Normalize

func (a Dimensions) Normalize() (time.Duration, []string, error)

Normalize returns the interval and tag dimensions separately. Returns 0 if no time interval is specified. Returns an error if multiple time dimensions exist or if non-VarRef dimensions are specified.

func (Dimensions) String

func (a Dimensions) String() string

String returns a string representation of the dimensions.

type DropConversationStatement

type DropConversationStatement struct {
	Name string
}

DropConversationStatement represents a command for removing a conversation from the database.

func (DropConversationStatement) RequiredPrivileges

func (s DropConversationStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a DropSeriesStatement.

func (*DropConversationStatement) String

func (s *DropConversationStatement) String() string

String returns a string representation of the drop conversation 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

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 DropOrganizationStatement

type DropOrganizationStatement struct {
	Name     string
	Database string
}

DropContinuousQueryStatement represents a command for removing a organization.

func (*DropOrganizationStatement) RequiredPrivileges

func (s *DropOrganizationStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege(s) required to execute a DropOrganizationStatement

func (*DropOrganizationStatement) String

func (s *DropOrganizationStatement) String() string

String returns a string representation of the 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) RequiredPrivileges

func (s *DropRetentionPolicyStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a DropRetentionPolicyStatement.

func (*DropRetentionPolicyStatement) String

String returns a string representation of the drop retention policy statement.

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

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

type DurationLiteral struct {
	Val time.Duration
}

DurationLiteral represents a duration literal.

func (*DurationLiteral) String

func (l *DurationLiteral) String() string

String returns a string representation of the literal.

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 Expr

type Expr interface {
	Node
	// contains filtered or unexported methods
}

Expr represents an expression that can be evaluated to a value.

func CloneExpr

func CloneExpr(expr Expr) Expr

CloneExpr returns a deep copy of the expression.

func ParseExpr

func ParseExpr(s string) (Expr, error)

ParseExpr parses an expression string and returns its AST representation.

func Reduce

func Reduce(expr Expr, valuer Valuer) Expr

Reduce evaluates expr using the available values in valuer. References that don't exist in valuer are ignored.

type Field

type Field struct {
	Expr  Expr
	Alias string
}

Field represents an expression retrieved from a select statement.

func (*Field) Name

func (f *Field) Name() string

Name returns the name of the field. Returns alias, if set. Otherwise uses the function name or variable name.

func (*Field) String

func (f *Field) String() string

String returns a string representation of the field.

type Fields

type Fields []*Field

Fields represents a list of fields.

func (Fields) Len

func (ff Fields) Len() int

Sort Interface for Fields

func (Fields) Less

func (ff Fields) Less(i, j int) bool

func (Fields) String

func (ff Fields) String() string

String returns a string representation of the fields.

func (Fields) Swap

func (ff Fields) Swap(i, j int)

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

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) RequiredPrivileges

func (s *GrantStatement) RequiredPrivileges() ExecutionPrivileges

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 Iterator

type Iterator interface {
	Next() (conversationsKey string, time int64, value interface{})
}

Iterator represents a forward-only iterator over a set of points. These are used by the MapFunctions in this file

type MapFunc

type MapFunc func(Iterator) interface{}

MapFunc represents a function used for mapping over a sequential series of data. The iterator represents a single group by interval

func InitializeMapFunc

func InitializeMapFunc(c *Call) (MapFunc, error)

InitializeMapFunc takes an aggregate call from the query and returns the MapFunc

type Node

type Node interface {
	String() string
	// contains filtered or unexported methods
}

Node represents a node in the MessageDB abstract syntax tree.

func Rewrite

func Rewrite(r Rewriter, node Node) Node

Rewrite recursively invokes the rewriter to replace each node. Nodes are traversed depth-first and rewritten from leaf to root.

func RewriteFunc

func RewriteFunc(node Node, fn func(Node) Node) Node

RewriteFunc rewrites a node hierarchy.

type NowValuer

type NowValuer struct {
	Now time.Time
}

NowValuer returns only the value for "now()".

func (*NowValuer) Value

func (v *NowValuer) Value(key string) (interface{}, bool)

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 Organization

type Organization struct {
	Database        string
	RetentionPolicy string
	Name            string
	Regex           *RegexLiteral
}

Organization represents a single organization used as a datasource.

func (*Organization) String

func (o *Organization) String() string

String returns a string representation of the conversation.

type Organizations

type Organizations []*Organization

Organizations represents a list of organizations

func (Organizations) String

func (oo Organizations) String() string

String returns a string representation of the organizations.

type ParenExpr

type ParenExpr struct {
	Expr Expr
}

ParenExpr represents a parenthesized expression.

func (*ParenExpr) String

func (e *ParenExpr) String() string

String returns a string representation of the parenthesized expression.

type ParseError

type ParseError struct {
	Message  string
	Found    string
	Expected []string
	Pos      Pos
}

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 MessageQL parser.

func NewParser

func NewParser(r io.Reader) *Parser

NewParser returns a new instance of Parser.

func (*Parser) ParseExpr

func (p *Parser) ParseExpr() (Expr, error)

ParseExpr parses an expression.

func (*Parser) ParseQuery

func (p *Parser) ParseQuery() (*Query, error)

ParseQuery parses an MessageQL string and returns a Query AST object.

func (*Parser) ParseStatement

func (p *Parser) ParseStatement() (Statement, error)

ParseStatement parses an MessageQL string and returns a Statement AST object.

type Pos

type Pos struct {
	Line int
	Char int
}

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

func NewPrivilege(p Privilege) *Privilege

NewPrivilege returns an initialized *Privilege.

func (Privilege) String

func (p Privilege) String() string

String returns a string representation of a Privilege.

type Processor

type Processor func(values []interface{}) interface{}

func GetProcessor

func GetProcessor(expr Expr, startIndex int) (Processor, int)

type Query

type Query struct {
	Statements Statements
}

Query represents a collection of ordered statements.

func ParseQuery

func ParseQuery(s string) (*Query, error)

ParseQuery parses a query string and returns its AST representation.

func (*Query) String

func (q *Query) String() string

String returns a string representation of the query.

type ReduceFunc

type ReduceFunc func([]interface{}) interface{}

ReduceFunc represents a function used for reducing mapper output.

type RegexLiteral

type RegexLiteral struct {
	Val *regexp.Regexp
}

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 Result

type Result struct {
	// StatementID is just the statement's position in the query. It's used
	// to combine statement results if they're being buffered in memory.
	StatementID int `json:"-"`
	Rows        Rows
	Err         error
}

Result represents a resultset returned from a single statement.

func (*Result) MarshalJSON

func (r *Result) MarshalJSON() ([]byte, error)

MarshalJSON encodes the result into JSON.

func (*Result) UnmarshalJSON

func (r *Result) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the data into the Result struct

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

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) RequiredPrivileges

func (s *RevokeStatement) RequiredPrivileges() ExecutionPrivileges

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

type Rewriter interface {
	Rewrite(Node) Node
}

Rewriter can be called by Rewrite to replace nodes in the AST hierarchy. The Rewrite() function is called once per node.

type Row

type Row struct {
	Name    string            `json:"name,omitempty"`
	Tags    map[string]string `json:"tags,omitempty"`
	Columns []string          `json:"columns,omitempty"`
	Values  [][]interface{}   `json:"values,omitempty"`
	Err     error             `json:"err,omitempty"`
}

Row represents a single row returned from the execution of a statement.

type Rows

type Rows []*Row

Rows represents a list of rows that can be sorted consistently by name/tag.

func (Rows) Len

func (p Rows) Len() int

func (Rows) Less

func (p Rows) Less(i, j int) bool

func (Rows) Swap

func (p Rows) Swap(i, j int)

type Scanner

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

Scanner represents a lexical scanner for MessageQL.

func NewScanner

func NewScanner(r io.Reader) *Scanner

NewScanner returns a new instance of Scanner.

func (*Scanner) Scan

func (s *Scanner) Scan() (tok Token, pos Pos, lit string)

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) ScanRegex

func (s *Scanner) ScanRegex() (tok Token, pos Pos, lit string)

type SelectStatement

type SelectStatement struct {
	// Expressions returned from the selection.
	Fields Fields

	// Expressions used for grouping the selection.
	Dimensions Dimensions

	// 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

	// if it's a query for raw data values (i.e. not an aggregate)
	IsRawQuery bool
}

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) FunctionCalls

func (s *SelectStatement) FunctionCalls() []*Call

FunctionCalls returns the Call objects from the query

func (*SelectStatement) HasWildcard

func (s *SelectStatement) HasWildcard() bool

HasWildcard returns whether or not the select statement has at least 1 wildcard

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) OnlyTimeDimensions

func (s *SelectStatement) OnlyTimeDimensions() bool

OnlyTimeDimensions returns true if the statement has a where clause with only time constraints

func (*SelectStatement) RequiredPrivileges

func (s *SelectStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute the SelectStatement.

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.

type SetPasswordUserStatement

type SetPasswordUserStatement struct {
	// Plain 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

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 ShowConversationsStatement

type ShowConversationsStatement struct {
	// Namespaces(s) the conversations are listed for.
	Sources Sources

	// An expression evaluated on a conversation 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
}

ShowConversationsStatement represents a command for listing conversations in the organization.

func (*ShowConversationsStatement) RequiredPrivileges

func (s *ShowConversationsStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a ShowConversationsStatement.

func (*ShowConversationsStatement) String

func (s *ShowConversationsStatement) String() string

String returns a string representation of the list series 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

RequiredPrivileges returns the privilege required to execute a ShowDatabasesStatement

func (*ShowDatabasesStatement) String

func (s *ShowDatabasesStatement) String() string

String returns a string representation of the list databases command.

type ShowDevicesForUserStatement

type ShowDevicesForUserStatement struct {
	// Name of the user to display privileges.
	Name string
}

ShowDevicesForUserStatement represents a command for listing user privileges.

func (*ShowDevicesForUserStatement) RequiredPrivileges

func (s *ShowDevicesForUserStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a ShowDevicesForUserStatement

func (*ShowDevicesForUserStatement) String

func (s *ShowDevicesForUserStatement) String() string

String returns a string representation of the show devices for user.

type ShowDiagnosticsStatement

type ShowDiagnosticsStatement struct{}

ShowDiagnosticsStatement represents a command for show node diagnostics.

func (*ShowDiagnosticsStatement) RequiredPrivileges

func (s *ShowDiagnosticsStatement) RequiredPrivileges() ExecutionPrivileges

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 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

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 ShowOrganizationMembersStatement

type ShowOrganizationMembersStatement struct {
	// Name of the user to display privileges.
	Name string

	Database string

	// Data source that fields are extracted from (optional)
	Sources Sources

	// Maximum number of rows to be returned.
	// Unlimited if zero.
	Limit int

	// Returns rows starting at an offset from the first row.
	Offset int
}

ShowOrganizationMembersStatement represents a command for listing user privileges.

func (*ShowOrganizationMembersStatement) RequiredPrivileges

func (s *ShowOrganizationMembersStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a ShowOrganizationMembersStatement

func (*ShowOrganizationMembersStatement) String

String returns a string representation of the show members for organization.

type ShowOrganizationsStatement

type ShowOrganizationsStatement struct{}

ShowOrganizationsStatement represents a command for listing organizations.

func (*ShowOrganizationsStatement) RequiredPrivileges

func (s *ShowOrganizationsStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a ShowOrganizationsStatement.

func (*ShowOrganizationsStatement) String

func (s *ShowOrganizationsStatement) String() string

String returns a string representation of the list continuous 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) RequiredPrivileges

func (s *ShowRetentionPoliciesStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege(s) required to execute a ShowRetentionPoliciesStatement

func (*ShowRetentionPoliciesStatement) String

String returns a string representation of a ShowRetentionPoliciesStatement.

type ShowServersStatement

type ShowServersStatement struct{}

ShowServersStatement represents a command for listing all servers.

func (*ShowServersStatement) RequiredPrivileges

func (s *ShowServersStatement) RequiredPrivileges() ExecutionPrivileges

RequiredPrivileges returns the privilege required to execute a ShowServersStatement

func (*ShowServersStatement) String

func (s *ShowServersStatement) String() string

String returns a string representation of the show servers command.

type ShowStatsStatement

type ShowStatsStatement struct {
	// Hostname or IP of the server for stats.
	Host string
}

ShowRetentionPoliciesStatement represents a command for displaying stats for a given server.

func (*ShowStatsStatement) RequiredPrivileges

func (s *ShowStatsStatement) RequiredPrivileges() ExecutionPrivileges

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 ShowUsersStatement

type ShowUsersStatement struct{}

ShowUsersStatement represents a command for listing users.

func (*ShowUsersStatement) RequiredPrivileges

func (s *ShowUsersStatement) RequiredPrivileges() ExecutionPrivileges

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 SortField

type SortField struct {
	// Name of the field
	Name string

	// Sort order.
	Ascending bool
}

SortField represents a field to sort results by.

func (*SortField) String

func (field *SortField) String() string

String returns a string representation of a sort field

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) String

func (a Sources) String() string

String returns a string representation of a Sources array.

type Statement

type Statement interface {
	Node

	RequiredPrivileges() ExecutionPrivileges
	// contains filtered or unexported methods
}

Statement represents a single command in MessageQL.

func MustParseStatement

func MustParseStatement(s string) Statement

MustParseStatement parses a statement string and returns its AST. Panic on error.

func ParseStatement

func ParseStatement(s string) (Statement, error)

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 TagSet

type TagSet struct {
	Tags       map[string]string
	Filters    []Expr
	SeriesKeys []string
	Key        []byte
}

TagSet is a fundamental concept within the query system. It represents a composite series, composed of multiple individual series that share a set of tag attributes.

func (*TagSet) AddFilter

func (t *TagSet) AddFilter(key string, filter Expr)

AddFilter adds a series-level filter to the Tagset.

type TimeLiteral

type TimeLiteral struct {
	Val time.Time
}

TimeLiteral represents a point-in-time literal.

func (*TimeLiteral) String

func (l *TimeLiteral) String() string

String returns a string representation of the literal.

type Token

type Token int

Token is a lexical token of the MessageDB SQL language.

const (
	ILLEGAL Token = iota
	EOF
	WS

	IDENT        // main
	NUMBER       // 12345.67
	DURATION_VAL // 13h
	STRING       // "abc"
	BADSTRING    // "abc
	BADESCAPE    // \q
	TRUE         // true
	FALSE        // false
	REGEX        // Regular expressions
	BADREGEX     // `.*

	ADD // +
	SUB // -
	MUL // *
	DIV // /

	AND // AND
	OR  // OR

	EQ       // =
	NEQ      // !=
	EQREGEX  // =~
	NEQREGEX // !~
	LT       // <
	LTE      // <=
	GT       // >
	GTE      // >=

	LPAREN    // (
	RPAREN    // )
	COMMA     // ,
	SEMICOLON // ;
	DOT       // .

	ALL
	ALTER
	AS
	ASC
	BEGIN
	BY
	CREATE
	CONTINUOUS
	CONVERSATION
	CONVERSATIONS
	DATABASE
	DATABASES
	DEFAULT
	DELETE
	DESC
	DEVICES
	DISTINCT
	DROP
	DURATION
	END
	EXISTS
	EXPLAIN
	FIELD
	FOR
	FROM
	GRANT
	GRANTS
	GROUP
	IF
	IN
	INF
	INNER
	INSERT
	INTO
	KEY
	KEYS
	LIMIT
	MEMBER
	MEMBERS
	OFFSET
	ON
	ORDER
	ORGANIZATION
	ORGANIZATIONS
	PASSWORD
	POLICY
	POLICIES
	PRIVILEGES
	QUERIES
	QUERY
	READ
	REPLICATION
	RETENTION
	REVOKE
	SELECT
	SERIES
	SERVERS
	SET
	SHOW
	SLIMIT
	STATS
	DIAGNOSTICS
	SOFFSET
	TAG
	TO
	USER
	USERS
	VALUES
	WHERE
	WITH
	WRITE
)

func Lookup

func Lookup(ident string) Token

Lookup returns the token associated with a given string.

func (Token) Precedence

func (tok Token) Precedence() int

Precedence returns the operator precedence of the binary operator token.

func (Token) String

func (tok Token) String() string

String returns the string representation of the token.

type UnmarshalFunc

type UnmarshalFunc func([]byte) (interface{}, error)

UnmarshalFunc represents a function that can take bytes from a mapper from remote server and marshal it into an interface the reducer can use

type Valuer

type Valuer interface {
	Value(key string) (interface{}, bool)
}

Valuer is the interface that wraps the Value() method.

Value returns the value and existence flag for a given key.

type VarRef

type VarRef struct {
	Val string
}

VarRef represents a reference to a variable.

func (*VarRef) String

func (r *VarRef) String() string

String returns a string representation of the variable reference.

type Visitor

type Visitor interface {
	Visit(Node) Visitor
}

Visitor can be called by Walk to traverse an AST hierarchy. The Visit() function is called once per node.

type Wildcard

type Wildcard struct{}

Wildcard represents a wild card expression.

func (*Wildcard) String

func (e *Wildcard) String() string

String returns a string representation of the wildcard.

Jump to

Keyboard shortcuts

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