Documentation ¶
Index ¶
- Constants
- Variables
- func IsBooleanArg(arg Expr) bool
- func IsFieldRefArg(arg Expr) bool
- func IsFloatArg(arg Expr) bool
- func IsIntegerArg(arg Expr) bool
- func IsNumericArg(arg Expr) bool
- func IsStreamOptionKeyword(_ Token, lit string) bool
- func IsStringArg(arg Expr) bool
- func IsTimeArg(arg Expr) bool
- func Walk(v Visitor, node Node)
- func WalkFunc(node Node, fn func(Node) bool)
- type AliasRef
- type ArrayType
- type ArrowExpr
- type BasicType
- type BetweenExpr
- type BinaryExpr
- type BooleanLiteral
- type BracketExpr
- type Call
- type CaseExpr
- type ColFuncField
- type ColonExpr
- type DataType
- type DescribeStreamStatement
- type DescribeTableStatement
- type Dimension
- type Dimensions
- type DropStreamStatement
- type DropTableStatement
- type ExplainStreamStatement
- type ExplainTableStatement
- type Expr
- type Field
- type FieldRef
- type FieldType
- type Fields
- type FuncType
- type IndexExpr
- type IntegerLiteral
- type Join
- type JoinType
- type Joins
- type JsonFieldRef
- type JsonStreamField
- type LikePattern
- type LimitExpr
- type Literal
- type MetaRef
- type NameNode
- type Node
- type NumberLiteral
- type Options
- type ParenExpr
- type PartitionExpr
- type RecType
- type SelectStatement
- type ShowStreamsStatement
- type ShowTablesStatement
- type SortField
- type SortFields
- type Source
- type Sources
- type Statement
- type StreamField
- type StreamFields
- type StreamName
- type StreamStmt
- type StreamType
- type StringLiteral
- type Table
- type TimeLiteral
- type Token
- type ValidateAbleExpr
- type ValueSetExpr
- type Visitor
- type WhenClause
- type Wildcard
- type Window
- type WindowType
Constants ¶
View Source
const ( DefaultStream = StreamName("$$default") AliasStream = StreamName("$$alias") )
View Source
const ( StreamKindLookup = "lookup" StreamKindScan = "scan" )
View Source
const ( RowkindInsert = "insert" RowkindUpdate = "update" RowkindUpsert = "upsert" RowkindDelete = "delete" )
View Source
const ( SELECT_LIT = "SELECT" CREATE = "CREATE" DROP = "DROP" EXPLAIN = "EXPLAIN" DESCRIBE = "DESCRIBE" SHOW = "SHOW" STREAM = "STREAM" TABLE = "TABLE" STREAMS = "STREAMS" TABLES = "TABLES" WITH = "WITH" DATASOURCE = "DATASOURCE" KEY = "KEY" FORMAT = "FORMAT" CONF_KEY = "CONF_KEY" TYPE = "TYPE" STRICT_VALIDATION = "STRICT_VALIDATION" TIMESTAMP = "TIMESTAMP" TIMESTAMP_FORMAT = "TIMESTAMP_FORMAT" RETAIN_SIZE = "RETAIN_SIZE" SHARED = "SHARED" SCHEMAID = "SCHEMAID" KIND = "KIND" DELIMITER = "DELIMITER" XBIGINT = "BIGINT" XFLOAT = "FLOAT" XSTRING = "STRING" XBYTEA = "BYTEA" XDATETIME = "DATETIME" XBOOLEAN = "BOOLEAN" XARRAY = "ARRAY" XSTRUCT = "STRUCT" )
Variables ¶
View Source
var COLUMN_SEPARATOR = Tokens[COLSEP]
View Source
var StreamDataTypes = map[string]DataType{ XBIGINT: BIGINT, XFLOAT: FLOAT, XSTRING: STRINGS, XBYTEA: BYTEA, XDATETIME: DATETIME, XBOOLEAN: BOOLEAN, XARRAY: ARRAY, XSTRUCT: STRUCT, }
View Source
var StreamTokens = map[string]struct{}{ DATASOURCE: {}, KEY: {}, FORMAT: {}, CONF_KEY: {}, TYPE: {}, STRICT_VALIDATION: {}, TIMESTAMP: {}, TIMESTAMP_FORMAT: {}, RETAIN_SIZE: {}, SHARED: {}, SCHEMAID: {}, KIND: {}, DELIMITER: {}, }
View Source
var StreamTypeMap = map[StreamType]string{ TypeStream: "stream", TypeTable: "table", }
View Source
var Tokens = []string{ ILLEGAL: "ILLEGAL", EOF: "EOF", AS: "AS", WS: "WS", IDENT: "IDENT", INTEGER: "INTEGER", NUMBER: "NUMBER", STRING: "STRING", SINGLEQUOTE: "SINGLEQUOTE", ADD: "+", SUB: "-", MUL: "*", DIV: "/", MOD: "%", BITWISE_AND: "&", BITWISE_OR: "|", BITWISE_XOR: "^", EQ: "=", NEQ: "!=", LT: "<", LTE: "<=", GT: ">", GTE: ">=", SUBSET: "[]", ARROW: "->", IN: "IN", ASTERISK: "*", COMMA: ",", LPAREN: "(", RPAREN: ")", LBRACKET: "[", RBRACKET: "]", HASH: "#", DOT: ".", SEMICOLON: ";", COLON: ":", COLSEP: "\007", SELECT: "SELECT", FROM: "FROM", JOIN: "JOIN", LEFT: "LEFT", INNER: "INNER", ON: "ON", WHERE: "WHERE", LIMIT: "LIMIT", GROUP: "GROUP", ORDER: "ORDER", HAVING: "HAVING", BY: "BY", ASC: "ASC", DESC: "DESC", FILTER: "FILTER", CASE: "CASE", WHEN: "WHEN", THEN: "THEN", ELSE: "ELSE", END: "END", OVER: "OVER", PARTITION: "PARTITION", AND: "AND", OR: "OR", TRUE: "TRUE", FALSE: "FALSE", NOTIN: "NOT IN", BETWEEN: "BETWEEN", NOTBETWEEN: "NOT BETWEEN", LIKE: "LIKE", NOTLIKE: "NOT LIKE", REPLACE: "REPLACE", EXCEPT: "EXCEPT", DD: "DD", HH: "HH", MI: "MI", SS: "SS", MS: "MS", }
Functions ¶
func IsBooleanArg ¶
func IsFieldRefArg ¶
func IsFloatArg ¶
func IsIntegerArg ¶
func IsNumericArg ¶
func IsStreamOptionKeyword ¶
func IsStringArg ¶
Types ¶
type AliasRef ¶
type AliasRef struct { // MUST have, It is used for evaluation Expression Expr // optional, lazy set when calculating isAggregate IsAggregate *bool // contains filtered or unexported fields }
func MockAliasRef ¶
func MockAliasRef(e Expr, r []StreamName, a *bool) *AliasRef
MockAliasRef is for testing only.
func NewAliasRef ¶
func (*AliasRef) SetRefSource ¶
SetRefSource only used for unit test
type BetweenExpr ¶
func (*BetweenExpr) String ¶
func (b *BetweenExpr) String() string
type BinaryExpr ¶
func (*BinaryExpr) String ¶
func (be *BinaryExpr) String() string
func (*BinaryExpr) ValidateExpr ¶
func (be *BinaryExpr) ValidateExpr() error
type BooleanLiteral ¶
type BooleanLiteral struct {
Val bool
}
func (*BooleanLiteral) String ¶
func (bl *BooleanLiteral) String() string
type BracketExpr ¶
type BracketExpr struct {
Expr Expr
}
func (*BracketExpr) String ¶
func (be *BracketExpr) String() string
type Call ¶
type Call struct { Name string FuncId int FuncType FuncType Args []Expr // This is used for analytic functions. // In planner, all analytic functions are planned to calculate in analytic_op which produce a new field. // This cachedField cached the new field name and when evaluating, just returned the field access evaluated value. CachedField string Cached bool Partition *PartitionExpr WhenExpr Expr // This is used for window functions. SortFields SortFields }
type CaseExpr ¶
type CaseExpr struct { // The compare value Expression. It can be a value Expression or nil. // When it is nil, the WhenClause Expr must be a logical(comparison) Expression Value Expr WhenClauses []*WhenClause ElseClause Expr }
type ColFuncField ¶
func (*ColFuncField) String ¶
func (fr *ColFuncField) String() string
type ColonExpr ¶
func (*ColonExpr) ValidateExpr ¶
type DescribeStreamStatement ¶
func (*DescribeStreamStatement) GetName ¶
func (dss *DescribeStreamStatement) GetName() string
type DescribeTableStatement ¶
func (*DescribeTableStatement) GetName ¶
func (dss *DescribeTableStatement) GetName() string
type Dimensions ¶
type Dimensions []Dimension
func (*Dimensions) GetGroups ¶
func (d *Dimensions) GetGroups() Dimensions
func (*Dimensions) GetWindow ¶
func (d *Dimensions) GetWindow() *Window
type DropStreamStatement ¶
func (*DropStreamStatement) GetName ¶
func (dss *DropStreamStatement) GetName() string
type DropTableStatement ¶
func (*DropTableStatement) GetName ¶
func (dss *DropTableStatement) GetName() string
type ExplainStreamStatement ¶
func (*ExplainStreamStatement) GetName ¶
func (ess *ExplainStreamStatement) GetName() string
type ExplainTableStatement ¶
func (*ExplainTableStatement) GetName ¶
func (ess *ExplainTableStatement) GetName() string
type Field ¶
func (*Field) IsSelectionField ¶
type FieldRef ¶
type FieldRef struct { // optional, bind in analyzer, empty means alias, default means not set // MUST have after binding for SQL fields. For 1.2,1.3 and 1.4, use special constant as stream name StreamName StreamName // optional, set only once. For selections, empty name will be assigned a default name // MUST have after binding, assign a name for 1.4 Name string // Only for alias *AliasRef }
FieldRef could be
- SQL Field 1.1 Explicit field "stream.col" 1.2 Implicit field "col" -> only exist in schemaless stream. Otherwise, explicit stream name will be bound 1.3 Alias field "expr as c" -> refer to an Expression or column
func (*FieldRef) RefSelection ¶
func (*FieldRef) RefSources ¶
func (fr *FieldRef) RefSources() []StreamName
RefSources Must call after binding or will get empty
func (*FieldRef) SetRefSource ¶
func (fr *FieldRef) SetRefSource(names []StreamName)
SetRefSource Only call this for alias field ref
type IntegerLiteral ¶
type IntegerLiteral struct {
Val int64
}
func (*IntegerLiteral) String ¶
func (il *IntegerLiteral) String() string
type JsonFieldRef ¶
type JsonFieldRef struct {
Name string
}
func (*JsonFieldRef) String ¶
func (fr *JsonFieldRef) String() string
type JsonStreamField ¶
type JsonStreamField struct { Type string `json:"type"` Items *JsonStreamField `json:"items,omitempty"` Properties map[string]*JsonStreamField `json:"properties,omitempty"` Selected bool }
type LikePattern ¶
func (*LikePattern) String ¶
func (l *LikePattern) String() string
type LimitExpr ¶
type LimitExpr struct {
LimitCount *IntegerLiteral
}
type MetaRef ¶
type MetaRef struct { StreamName StreamName Name string }
type NumberLiteral ¶
type NumberLiteral struct {
Val float64
}
func (*NumberLiteral) String ¶
func (nl *NumberLiteral) String() string
type Options ¶
type Options struct { DATASOURCE string `json:"datasource,omitempty"` KEY string `json:"key,omitempty"` FORMAT string `json:"format,omitempty"` CONF_KEY string `json:"confKey,omitempty"` TYPE string `json:"type,omitempty"` STRICT_VALIDATION bool `json:"strictValidation,omitempty"` TIMESTAMP string `json:"timestamp,omitempty"` TIMESTAMP_FORMAT string `json:"timestampFormat,omitempty"` SHARED bool `json:"shared,omitempty"` SCHEMAID string `json:"schemaid,omitempty"` // for scan table only RETAIN_SIZE int `json:"retainSize,omitempty"` // for table only, to distinguish lookup & scan KIND string `json:"kind,omitempty"` // for delimited format only DELIMITER string `json:"delimiter,omitempty"` RuleID string `json:"-"` Schema map[string]*JsonStreamField `json:"-"` IsWildCard bool `json:"-"` IsSchemaLess bool `json:"-"` StreamName string `json:"-"` }
Options The stream AST tree
type PartitionExpr ¶
type PartitionExpr struct {
Exprs []Expr
}
func (*PartitionExpr) String ¶
func (pe *PartitionExpr) String() string
type RecType ¶
type RecType struct { StreamFields StreamFields FieldType }
type SelectStatement ¶
type SelectStatement struct { Fields Fields Sources Sources Joins Joins Condition Expr Limit Expr Dimensions Dimensions Having Expr SortFields SortFields Statement }
type ShowStreamsStatement ¶
type ShowStreamsStatement struct {
Statement
}
type ShowTablesStatement ¶
type ShowTablesStatement struct {
Statement
}
type SortField ¶
type SortFields ¶
type SortFields []SortField
type StreamField ¶
func (*StreamField) MarshalJSON ¶
func (u *StreamField) MarshalJSON() ([]byte, error)
type StreamFields ¶
type StreamFields []StreamField
func (*StreamFields) ToJsonSchema ¶
func (sf *StreamFields) ToJsonSchema() map[string]*JsonStreamField
func (*StreamFields) UnmarshalFromMap ¶
func (sf *StreamFields) UnmarshalFromMap(data map[string]*JsonStreamField) error
func (*StreamFields) UnmarshalJSON ¶
func (sf *StreamFields) UnmarshalJSON(data []byte) error
UnmarshalJSON The json format follows json schema
type StreamName ¶
type StreamName string
type StreamStmt ¶
type StreamStmt struct { Name StreamName StreamFields StreamFields Options *Options StreamType StreamType // default to TypeStream Statement }
type StringLiteral ¶
type StringLiteral struct {
Val string
}
func (*StringLiteral) String ¶
func (sl *StringLiteral) String() string
type TimeLiteral ¶
type TimeLiteral struct {
Val Token
}
func (*TimeLiteral) String ¶
func (tl *TimeLiteral) String() string
type Token ¶
type Token int
const ( // Special Tokens ILLEGAL Token = iota EOF WS COMMENT AS // Literals IDENT // main INTEGER // 12345 NUMBER // 12345.67 STRING // "abc" SINGLEQUOTE // 'abc' BADSTRING // "abc // ADD and the following ADD // + SUB // - MUL // * DIV // / MOD // % BITWISE_AND // & BITWISE_OR // | BITWISE_XOR // ^ AND // AND OR // OR EQ // = NEQ // != LT // < LTE // <= GT // > GTE // >= SUBSET //[ ARROW //-> IN // IN NOT // NOT NOTIN // NOT BETWEEN NOTBETWEEN LIKE NOTLIKE REPLACE EXCEPT // Misc characters ASTERISK // * COMMA // , LPAREN // ( RPAREN // ) LBRACKET //[ RBRACKET //] HASH // # DOT // . COLON //: SEMICOLON //; COLSEP //\007 // Keywords SELECT FROM JOIN INNER LEFT RIGHT FULL CROSS ON WHERE LIMIT GROUP ORDER HAVING BY ASC DESC FILTER CASE WHEN THEN ELSE END OVER PARTITION TRUE FALSE DD HH MI SS MS )
func (Token) AllowedSFNToken ¶
Allowed special field name token
func (Token) AllowedSourceToken ¶
func (Token) IsOperator ¶
func (Token) IsTimeLiteral ¶
func (Token) Precedence ¶
type ValidateAbleExpr ¶
type ValidateAbleExpr interface {
ValidateExpr() error
}
type ValueSetExpr ¶
func (*ValueSetExpr) String ¶
func (c *ValueSetExpr) String() string
type WhenClause ¶
func (*WhenClause) String ¶
func (w *WhenClause) String() string
type Window ¶
type Window struct { TriggerCondition Expr WindowType WindowType Delay *IntegerLiteral Length *IntegerLiteral Interval *IntegerLiteral TimeUnit *TimeLiteral Filter Expr Expr }
type WindowType ¶
type WindowType int
const ( NOT_WINDOW WindowType = iota TUMBLING_WINDOW HOPPING_WINDOW SLIDING_WINDOW SESSION_WINDOW COUNT_WINDOW )
func (WindowType) String ¶
func (w WindowType) String() string
Click to show internal directories.
Click to hide internal directories.