Documentation ¶
Overview ¶
Package rel are the AST Structures and Parsers for the SQL, FilterQL, and Expression dialects.
Package rel is a generated protocol buffer package. It is generated from these files: sql.proto It has these top-level messages: SqlStatementPb SqlSelectPb SqlSourcePb SqlWherePb ProjectionPb ResultColumnPb KvInt ColumnPb CommandColumnPb
Index ¶
- Variables
- func EqualWith(l, r u.JsonHelper) bool
- func HelperString(w expr.DialectWriter, jh u.JsonHelper)
- func MapIntFromPb(kv []KvInt) map[string]int
- func NewSqlDialect() expr.DialectWriter
- func ParseJsonArray(pg expr.TokenPager) ([]interface{}, error)
- func ParseJsonObject(pg expr.TokenPager, jh u.JsonHelper) error
- func ParseKeyValue(pg expr.TokenPager, jh u.JsonHelper) error
- func ParseWith(pg expr.TokenPager) (u.JsonHelper, error)
- type Column
- func (m *Column) Asc() bool
- func (m *Column) Copy() *Column
- func (m *Column) CopyRewrite(alias string) *Column
- func (m *Column) CountStar() bool
- func (m *Column) Equal(c *Column) bool
- func (m *Column) InFinalProjection() bool
- func (m *Column) IsLiteral() bool
- func (m *Column) IsLiteralOrFunc() bool
- func (m *Column) Key() string
- func (m *Column) LeftRight() (string, string, bool)
- func (m *Column) String() string
- func (m *Column) ToPB() *ColumnPb
- func (m *Column) WriteDialect(w expr.DialectWriter)
- type ColumnPb
- func (*ColumnPb) Descriptor() ([]byte, []int)
- func (m *ColumnPb) GetAgg() bool
- func (m *ColumnPb) GetAs() string
- func (m *ColumnPb) GetAsQuoteByte() []byte
- func (m *ColumnPb) GetComment() string
- func (m *ColumnPb) GetExpr() *expr.NodePb
- func (m *ColumnPb) GetGuard() *expr.NodePb
- func (m *ColumnPb) GetIndex() int32
- func (m *ColumnPb) GetLeft() string
- func (m *ColumnPb) GetOrder() string
- func (m *ColumnPb) GetOriginalAs() string
- func (m *ColumnPb) GetParentIndex() int32
- func (m *ColumnPb) GetRight() string
- func (m *ColumnPb) GetSourceField() string
- func (m *ColumnPb) GetSourceIndex() int32
- func (m *ColumnPb) GetSourceQuote() []byte
- func (m *ColumnPb) GetStar() bool
- func (m *ColumnPb) Marshal() (data []byte, err error)
- func (m *ColumnPb) MarshalTo(data []byte) (int, error)
- func (*ColumnPb) ProtoMessage()
- func (m *ColumnPb) Reset()
- func (m *ColumnPb) Size() (n int)
- func (m *ColumnPb) String() string
- func (m *ColumnPb) Unmarshal(data []byte) error
- type Columns
- func (m *Columns) AliasedFieldNames() []string
- func (m *Columns) ByAs(as string) (*Column, bool)
- func (m *Columns) ByName(name string) (*Column, bool)
- func (m Columns) Equal(cols Columns) bool
- func (m *Columns) FieldNames() []string
- func (m *Columns) String() string
- func (m *Columns) UnAliasedFieldNames() []string
- func (m *Columns) WriteDialect(w expr.DialectWriter)
- type ColumnsStatement
- type CommandColumn
- type CommandColumnPb
- func (*CommandColumnPb) Descriptor() ([]byte, []int)
- func (m *CommandColumnPb) GetExpr() *expr.NodePb
- func (m *CommandColumnPb) GetName() string
- func (m *CommandColumnPb) Marshal() (data []byte, err error)
- func (m *CommandColumnPb) MarshalTo(data []byte) (int, error)
- func (*CommandColumnPb) ProtoMessage()
- func (m *CommandColumnPb) Reset()
- func (m *CommandColumnPb) Size() (n int)
- func (m *CommandColumnPb) String() string
- func (m *CommandColumnPb) Unmarshal(data []byte) error
- type CommandColumns
- type DdlColumn
- type Filter
- type FilterQLParser
- func (m FilterQLParser) ClauseEnd() bool
- func (f *FilterQLParser) FuncResolver(funcs expr.FuncResolver) *FilterQLParser
- func (m FilterQLParser) IsEnd() bool
- func (f *FilterQLParser) ParseFilter() (*FilterSelect, error)
- func (f *FilterQLParser) ParseFilterSelects() (stmts []*FilterSelect, err error)
- func (f *FilterQLParser) ParseFilters() (stmts []*FilterStatement, err error)
- type FilterSelect
- type FilterStatement
- type KvInt
- func (*KvInt) Descriptor() ([]byte, []int)
- func (m *KvInt) GetK() string
- func (m *KvInt) GetV() int32
- func (m *KvInt) Marshal() (data []byte, err error)
- func (m *KvInt) MarshalTo(data []byte) (int, error)
- func (*KvInt) ProtoMessage()
- func (m *KvInt) Reset()
- func (m *KvInt) Size() (n int)
- func (m *KvInt) String() string
- func (m *KvInt) Unmarshal(data []byte) error
- type ParseError
- type PreparedStatement
- type Projection
- type ProjectionPb
- func (*ProjectionPb) Descriptor() ([]byte, []int)
- func (m *ProjectionPb) GetColNames() []string
- func (m *ProjectionPb) GetColumns() []*ResultColumnPb
- func (m *ProjectionPb) GetDistinct() bool
- func (m *ProjectionPb) GetFinal() bool
- func (m *ProjectionPb) Marshal() (data []byte, err error)
- func (m *ProjectionPb) MarshalTo(data []byte) (int, error)
- func (*ProjectionPb) ProtoMessage()
- func (m *ProjectionPb) Reset()
- func (m *ProjectionPb) Size() (n int)
- func (m *ProjectionPb) String() string
- func (m *ProjectionPb) Unmarshal(data []byte) error
- type ResultColumn
- type ResultColumnPb
- func (*ResultColumnPb) Descriptor() ([]byte, []int)
- func (m *ResultColumnPb) GetAs() string
- func (m *ResultColumnPb) GetColPos() int32
- func (m *ResultColumnPb) GetColumn() *ColumnPb
- func (m *ResultColumnPb) GetFinal() bool
- func (m *ResultColumnPb) GetName() string
- func (m *ResultColumnPb) GetStar() bool
- func (m *ResultColumnPb) GetValueType() int32
- func (m *ResultColumnPb) Marshal() (data []byte, err error)
- func (m *ResultColumnPb) MarshalTo(data []byte) (int, error)
- func (*ResultColumnPb) ProtoMessage()
- func (m *ResultColumnPb) Reset()
- func (m *ResultColumnPb) Size() (n int)
- func (m *ResultColumnPb) String() string
- func (m *ResultColumnPb) Unmarshal(data []byte) error
- type ResultColumns
- type SqlAlter
- type SqlCommand
- type SqlCreate
- type SqlDelete
- type SqlDescribe
- type SqlDrop
- type SqlInsert
- type SqlInto
- type SqlSelect
- func (m *SqlSelect) AddColumn(colArg Column) error
- func (m *SqlSelect) AliasedColumns() map[string]*Column
- func (m *SqlSelect) ColIndexes() map[string]int
- func (m *SqlSelect) Copy() *SqlSelect
- func (m *SqlSelect) CountStar() bool
- func (m *SqlSelect) Equal(ss SqlStatement) bool
- func (m *SqlSelect) Finalize() error
- func (m *SqlSelect) FingerPrintID() int64
- func (m *SqlSelect) FromPB(spb *SqlSelectPb) *SqlSelect
- func (m *SqlSelect) IsAggQuery() bool
- func (m *SqlSelect) IsLiteral() bool
- func (m *SqlSelect) Keyword() lex.TokenType
- func (m *SqlSelect) Rewrite()
- func (m *SqlSelect) RewriteAsRawSelect()
- func (m *SqlSelect) SetSystemQry()
- func (m *SqlSelect) String() string
- func (m *SqlSelect) SystemQry() bool
- func (m *SqlSelect) ToPB() *SqlSelectPb
- func (m *SqlSelect) ToPbStatement() *SqlStatementPb
- func (m *SqlSelect) UnAliasedColumns() map[string]*Column
- func (m *SqlSelect) WriteDialect(w expr.DialectWriter)
- type SqlSelectPb
- func (*SqlSelectPb) Descriptor() ([]byte, []int)
- func (m *SqlSelectPb) GetAlias() string
- func (m *SqlSelectPb) GetColumns() []*ColumnPb
- func (m *SqlSelectPb) GetDb() string
- func (m *SqlSelectPb) GetDistinct() bool
- func (m *SqlSelectPb) GetFinalized() bool
- func (m *SqlSelectPb) GetFrom() []*SqlSourcePb
- func (m *SqlSelectPb) GetGroupBy() []*ColumnPb
- func (m *SqlSelectPb) GetHaving() *expr.NodePb
- func (m *SqlSelectPb) GetInto() string
- func (m *SqlSelectPb) GetIsAgg() bool
- func (m *SqlSelectPb) GetLimit() int32
- func (m *SqlSelectPb) GetOffset() int32
- func (m *SqlSelectPb) GetOrderBy() []*ColumnPb
- func (m *SqlSelectPb) GetProjection() *ProjectionPb
- func (m *SqlSelectPb) GetRaw() string
- func (m *SqlSelectPb) GetSchemaqry() bool
- func (m *SqlSelectPb) GetStar() bool
- func (m *SqlSelectPb) GetWhere() *SqlWherePb
- func (m *SqlSelectPb) GetWith() []byte
- func (m *SqlSelectPb) Marshal() (data []byte, err error)
- func (m *SqlSelectPb) MarshalTo(data []byte) (int, error)
- func (*SqlSelectPb) ProtoMessage()
- func (m *SqlSelectPb) Reset()
- func (m *SqlSelectPb) Size() (n int)
- func (m *SqlSelectPb) String() string
- func (m *SqlSelectPb) Unmarshal(data []byte) error
- type SqlShow
- type SqlSource
- func (m *SqlSource) BuildColIndex(colNames []string) error
- func (m *SqlSource) ColumnPositions() map[string]int
- func (m *SqlSource) Equal(s *SqlSource) bool
- func (m *SqlSource) Finalize() error
- func (m *SqlSource) FromPB(n *SqlSourcePb) *SqlSource
- func (m *SqlSource) IsLiteral() bool
- func (m *SqlSource) JoinNodes() []expr.Node
- func (m *SqlSource) Keyword() lex.TokenType
- func (m *SqlSource) Rewrite(parentStmt *SqlSelect) *SqlSelect
- func (m *SqlSource) SourceName() string
- func (m *SqlSource) String() string
- func (m *SqlSource) ToPB() *SqlSourcePb
- func (m *SqlSource) UnAliasedColumns() map[string]*Column
- func (m *SqlSource) WriteDialect(w expr.DialectWriter)
- type SqlSourcePb
- func (*SqlSourcePb) Descriptor() ([]byte, []int)
- func (m *SqlSourcePb) GetAlias() string
- func (m *SqlSourcePb) GetAliasInner() string
- func (m *SqlSourcePb) GetColIndex() []KvInt
- func (m *SqlSourcePb) GetColumns() []*ColumnPb
- func (m *SqlSourcePb) GetFinal() bool
- func (m *SqlSourcePb) GetJoinExpr() *expr.NodePb
- func (m *SqlSourcePb) GetJoinNodes() []*expr.NodePb
- func (m *SqlSourcePb) GetJoinType() int32
- func (m *SqlSourcePb) GetLeftOrRight() int32
- func (m *SqlSourcePb) GetName() string
- func (m *SqlSourcePb) GetOp() int32
- func (m *SqlSourcePb) GetRaw() string
- func (m *SqlSourcePb) GetSeekable() bool
- func (m *SqlSourcePb) GetSource() *SqlSelectPb
- func (m *SqlSourcePb) GetSubQuery() *SqlSelectPb
- func (m *SqlSourcePb) Marshal() (data []byte, err error)
- func (m *SqlSourcePb) MarshalTo(data []byte) (int, error)
- func (*SqlSourcePb) ProtoMessage()
- func (m *SqlSourcePb) Reset()
- func (m *SqlSourcePb) Size() (n int)
- func (m *SqlSourcePb) String() string
- func (m *SqlSourcePb) Unmarshal(data []byte) error
- type SqlSourceStatement
- type SqlStatement
- type SqlStatementPb
- func (*SqlStatementPb) Descriptor() ([]byte, []int)
- func (m *SqlStatementPb) GetProjection() *ProjectionPb
- func (m *SqlStatementPb) GetSelect() *SqlSelectPb
- func (m *SqlStatementPb) GetSource() *SqlSourcePb
- func (m *SqlStatementPb) Marshal() (data []byte, err error)
- func (m *SqlStatementPb) MarshalTo(data []byte) (int, error)
- func (*SqlStatementPb) ProtoMessage()
- func (m *SqlStatementPb) Reset()
- func (m *SqlStatementPb) Size() (n int)
- func (m *SqlStatementPb) String() string
- func (m *SqlStatementPb) Unmarshal(data []byte) error
- type SqlTokenPager
- type SqlUpdate
- type SqlUpsert
- type SqlWhere
- type SqlWherePb
- func (*SqlWherePb) Descriptor() ([]byte, []int)
- func (m *SqlWherePb) GetExpr() *expr.NodePb
- func (m *SqlWherePb) GetOp() int32
- func (m *SqlWherePb) GetSource() *SqlSelectPb
- func (m *SqlWherePb) Marshal() (data []byte, err error)
- func (m *SqlWherePb) MarshalTo(data []byte) (int, error)
- func (*SqlWherePb) ProtoMessage()
- func (m *SqlWherePb) Reset()
- func (m *SqlWherePb) Size() (n int)
- func (m *SqlWherePb) String() string
- func (m *SqlWherePb) Unmarshal(data []byte) error
- type Sqlbridge
- type ValueColumn
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthSql = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowSql = fmt.Errorf("proto: integer overflow") )
var ( // SqlKeywords the SqlKeywords list SqlKeywords = []string{"select", "insert", "update", "delete", "from", "where", "as", "into", "limit", "exists", "in", "contains", "include", "not", "and", "having", "or", "null", "group", "order", "offset", "include", "all", "any", "some"} )
Functions ¶
func EqualWith ¶
func EqualWith(l, r u.JsonHelper) bool
EqualWith compare two with helpers for equality.
func HelperString ¶
func HelperString(w expr.DialectWriter, jh u.JsonHelper)
HelperString Convert a Helper into key/value string
func MapIntFromPb ¶
func NewSqlDialect ¶
func NewSqlDialect() expr.DialectWriter
func ParseJsonArray ¶
func ParseJsonArray(pg expr.TokenPager) ([]interface{}, error)
func ParseJsonObject ¶
func ParseJsonObject(pg expr.TokenPager, jh u.JsonHelper) error
func ParseKeyValue ¶
func ParseKeyValue(pg expr.TokenPager, jh u.JsonHelper) error
func ParseWith ¶
func ParseWith(pg expr.TokenPager) (u.JsonHelper, error)
Types ¶
type Column ¶
type Column struct { ParentIndex int // slice idx position in parent query cols Index int // slice idx position in original query cols SourceIndex int // slice idx position in source []driver.Value SourceField string // field name of underlying field SourceOriginal string // field name of underlying field without the "left.right" parse As string // As field, auto-populate the Field Name if exists Comment string // optional in-line comments Order string // (ASC | DESC) Star bool // * Agg bool // aggregate function column? count(*), avg(x) etc Expr expr.Node // Expression, optional, often Identity.Node Guard expr.Node // column If guard, non-standard sql column guard // contains filtered or unexported fields }
Column represents the Column as expressed in a [SELECT] expression
func NewColumnFromToken ¶
func NewColumnValue ¶
func (*Column) CopyRewrite ¶
CopyRewrite Create a new copy of this column for rewrite purposes removing alias
func (*Column) InFinalProjection ¶
func (*Column) IsLiteralOrFunc ¶
func (*Column) LeftRight ¶
Return left, right values if is of form `table.column` and also return true/false for if it even has left/right
func (*Column) WriteDialect ¶
func (m *Column) WriteDialect(w expr.DialectWriter)
type ColumnPb ¶
type ColumnPb struct { SourceQuote []byte `protobuf:"bytes,1,opt,name=sourceQuote" json:"sourceQuote,omitempty"` AsQuoteByte []byte `protobuf:"bytes,2,opt,name=asQuoteByte" json:"asQuoteByte,omitempty"` OriginalAs *string `protobuf:"bytes,3,opt,name=originalAs" json:"originalAs,omitempty"` Left *string `protobuf:"bytes,4,opt,name=left" json:"left,omitempty"` Right *string `protobuf:"bytes,5,opt,name=right" json:"right,omitempty"` ParentIndex int32 `protobuf:"varint,6,opt,name=parentIndex" json:"parentIndex"` Index int32 `protobuf:"varint,7,opt,name=index" json:"index"` SourceIndex int32 `protobuf:"varint,8,opt,name=sourceIndex" json:"sourceIndex"` SourceField *string `protobuf:"bytes,9,opt,name=sourceField" json:"sourceField,omitempty"` As string `protobuf:"bytes,11,opt,name=as" json:"as"` Comment *string `protobuf:"bytes,12,opt,name=comment" json:"comment,omitempty"` Order *string `protobuf:"bytes,13,opt,name=order" json:"order,omitempty"` Star *bool `protobuf:"varint,14,opt,name=star" json:"star,omitempty"` Agg bool `protobuf:"varint,15,opt,name=agg" json:"agg"` Expr *expr.NodePb `protobuf:"bytes,16,opt,name=Expr,json=expr" json:"Expr,omitempty"` Guard *expr.NodePb `protobuf:"bytes,17,opt,name=Guard,json=guard" json:"Guard,omitempty"` XXX_unrecognized []byte `json:"-"` }
func ColumnsToPb ¶
func (*ColumnPb) Descriptor ¶
func (*ColumnPb) GetAsQuoteByte ¶
func (*ColumnPb) GetComment ¶
func (*ColumnPb) GetOriginalAs ¶
func (*ColumnPb) GetParentIndex ¶
func (*ColumnPb) GetSourceField ¶
func (*ColumnPb) GetSourceIndex ¶
func (*ColumnPb) GetSourceQuote ¶
func (*ColumnPb) ProtoMessage ¶
func (*ColumnPb) ProtoMessage()
type Columns ¶
type Columns []*Column
Columns List of Columns in SELECT [columns]
func ColumnsFromPb ¶
func (*Columns) AliasedFieldNames ¶
func (*Columns) FieldNames ¶
func (*Columns) UnAliasedFieldNames ¶
func (*Columns) WriteDialect ¶
func (m *Columns) WriteDialect(w expr.DialectWriter)
type ColumnsStatement ¶
ColumnsStatement is a statement interface for those statements that have columns that need to be added during parse.
type CommandColumn ¶
type CommandColumn struct { Expr expr.Node // column expression Name string // Original path/name for command field }
CommandColumn is single column such as "autocommit"
func (*CommandColumn) FingerPrint ¶
func (m *CommandColumn) FingerPrint(r rune) string
func (*CommandColumn) Key ¶
func (m *CommandColumn) Key() string
func (*CommandColumn) String ¶
func (m *CommandColumn) String() string
func (*CommandColumn) WriteDialect ¶
func (m *CommandColumn) WriteDialect(w expr.DialectWriter)
type CommandColumnPb ¶
type CommandColumnPb struct { Expr *expr.NodePb `protobuf:"bytes,1,opt,name=Expr,json=expr" json:"Expr,omitempty"` Name string `protobuf:"bytes,2,req,name=name" json:"name"` XXX_unrecognized []byte `json:"-"` }
func (*CommandColumnPb) Descriptor ¶
func (*CommandColumnPb) Descriptor() ([]byte, []int)
func (*CommandColumnPb) GetExpr ¶
func (m *CommandColumnPb) GetExpr() *expr.NodePb
func (*CommandColumnPb) GetName ¶
func (m *CommandColumnPb) GetName() string
func (*CommandColumnPb) Marshal ¶
func (m *CommandColumnPb) Marshal() (data []byte, err error)
func (*CommandColumnPb) ProtoMessage ¶
func (*CommandColumnPb) ProtoMessage()
func (*CommandColumnPb) Reset ¶
func (m *CommandColumnPb) Reset()
func (*CommandColumnPb) Size ¶
func (m *CommandColumnPb) Size() (n int)
func (*CommandColumnPb) String ¶
func (m *CommandColumnPb) String() string
func (*CommandColumnPb) Unmarshal ¶
func (m *CommandColumnPb) Unmarshal(data []byte) error
type CommandColumns ¶
type CommandColumns []*CommandColumn
CommandColumns SQL commands such as:
set autocommit SET @@local.sort_buffer_size=10000; USE myschema;
func (*CommandColumns) String ¶
func (m *CommandColumns) String() string
func (*CommandColumns) WriteDialect ¶
func (m *CommandColumns) WriteDialect(w expr.DialectWriter)
type DdlColumn ¶
type DdlColumn struct { Kw lex.TokenType // initial keyword (identity for normal, constraint, primary) Null bool // Do we support NULL? AutoIncrement bool // auto increment IndexType string // index_type IndexCols []string // index_col_name RefTable string // refererence table RefCols []string // ref cols Default expr.Node // Default value DataType string // data type DataTypeSize int // Data Type Size: varchar(2000) DataTypeArgs []expr.Node // data type args Key lex.TokenType // UNIQUE | PRIMARY Name string // name Comment string // optional in-line comments Expr expr.Node // Expression, optional, often Identity.Node but could be composite key }
DdlColumn represents the Data Definition Column
type Filter ¶
type Filter interface {
String() string
}
Filter interface for Filter Statements (either Filter/FilterSelect)
type FilterQLParser ¶
type FilterQLParser struct {
// contains filtered or unexported fields
}
FilterQLParser
func NewFilterParser ¶
func NewFilterParser(filter string) *FilterQLParser
func NewFilterParserfuncs ¶
func NewFilterParserfuncs(filter string, funcs expr.FuncResolver) *FilterQLParser
func (*FilterQLParser) FuncResolver ¶
func (f *FilterQLParser) FuncResolver(funcs expr.FuncResolver) *FilterQLParser
FuncResolver sets the function resolver to use during parsing. By default we only use the Global resolver. But if you set a function resolver we'll use that first and then fall back to the Global resolver.
func (*FilterQLParser) ParseFilter ¶
func (f *FilterQLParser) ParseFilter() (*FilterSelect, error)
ParseFilterQL Parses a FilterQL statement
func (*FilterQLParser) ParseFilterSelects ¶
func (f *FilterQLParser) ParseFilterSelects() (stmts []*FilterSelect, err error)
func (*FilterQLParser) ParseFilters ¶
func (f *FilterQLParser) ParseFilters() (stmts []*FilterStatement, err error)
type FilterSelect ¶
type FilterSelect struct { *FilterStatement Columns Columns }
FilterSelect is a Filter but also has projected columns
func NewFilterSelect ¶
func NewFilterSelect() *FilterSelect
func ParseFilterSelect ¶
func ParseFilterSelect(query string) (*FilterSelect, error)
ParseFilterSelect Parse a single Select-Filter statement from text Select-Filters are statements of following form
"SELECT" [COLUMNS] (FILTER | WHERE) FilterExpression "FILTER" FilterExpression
func ParseFilterSelects ¶
func ParseFilterSelects(statement string) (stmts []*FilterSelect, err error)
ParseFilterSelects Parse 1-n Select-Filter statements from text Select-Filters are statements of following form
"SELECT" [COLUMNS] (FILTER | WHERE) FilterExpression "FILTER" FilterExpression
func (*FilterSelect) AddColumn ¶
func (m *FilterSelect) AddColumn(colArg Column) error
func (*FilterSelect) Equal ¶
func (m *FilterSelect) Equal(s *FilterSelect) bool
Equal Checks for deep equality
func (*FilterSelect) FingerPrintID ¶
func (m *FilterSelect) FingerPrintID() int64
FingerPrint consistent hashed int value of FingerPrint above
func (*FilterSelect) String ¶
func (m *FilterSelect) String() string
String representation of FilterSelect
func (*FilterSelect) WriteDialect ¶
func (m *FilterSelect) WriteDialect(w expr.DialectWriter)
type FilterStatement ¶
type FilterStatement struct { Description string // initial pre-start comments Raw string // full original raw statement Filter expr.Node // FILTER <filter_expr> Where expr.Node // WHERE <expr> [AND <expr>] syntax OrderBy Columns // order by From string // From is optional Limit int // Limit Alias string // Non-Standard sql, alias/name of sql another way of expression Prepared Statement With u.JsonHelper // Non-Standard SQL for properties/config info, similar to Cassandra with, purse json // contains filtered or unexported fields }
FilterStatement is a statement of type = Filter
func MustParseFilter ¶
func MustParseFilter(statement string) *FilterStatement
func MustParseFilters ¶
func MustParseFilters(statement string) []*FilterStatement
func NewFilterStatement ¶
func NewFilterStatement() *FilterStatement
NewFilterStatement Create A FilterStatement
func ParseFilterQL ¶
func ParseFilterQL(filter string) (*FilterStatement, error)
ParseFilterQL Parses a FilterQL statement
func ParseFilters ¶
func ParseFilters(statement string) (stmts []*FilterStatement, err error)
ParseFilters Parse a list of Filter statement's from text
func (*FilterStatement) Equal ¶
func (m *FilterStatement) Equal(s *FilterStatement) bool
func (*FilterStatement) FingerPrintID ¶
func (m *FilterStatement) FingerPrintID() int64
FingerPrint consistent hashed int value of FingerPrint above
func (*FilterStatement) Includes ¶
func (m *FilterStatement) Includes() []string
Includes Recurse this statement and find all includes
func (*FilterStatement) String ¶
func (m *FilterStatement) String() string
String representation of FilterStatement
func (*FilterStatement) WriteDialect ¶
func (m *FilterStatement) WriteDialect(w expr.DialectWriter)
type KvInt ¶
type KvInt struct { K string `protobuf:"bytes,1,req,name=k" json:"k"` V int32 `protobuf:"varint,2,req,name=v" json:"v"` XXX_unrecognized []byte `json:"-"` }
func (*KvInt) Descriptor ¶
func (*KvInt) ProtoMessage ¶
func (*KvInt) ProtoMessage()
type ParseError ¶
type ParseError struct {
// contains filtered or unexported fields
}
ParseError type
type PreparedStatement ¶
type PreparedStatement struct { Alias string Statement SqlStatement }
PreparedStatement Prepared/Aliased SQL statement
func NewPreparedStatement ¶
func NewPreparedStatement() *PreparedStatement
func (*PreparedStatement) Keyword ¶
func (m *PreparedStatement) Keyword() lex.TokenType
func (*PreparedStatement) String ¶
func (m *PreparedStatement) String() string
func (*PreparedStatement) WriteDialect ¶
func (m *PreparedStatement) WriteDialect(w expr.DialectWriter)
type Projection ¶
type Projection struct { Distinct bool Final bool // Is this a Final Projection? or intermiediate? Columns ResultColumns // contains filtered or unexported fields }
Projection describes the results to expect from sql statement ie the ResultColumns for a result-set
func NewProjection ¶
func NewProjection() *Projection
func ProjectionFromPb ¶
func ProjectionFromPb(pb *ProjectionPb) *Projection
func (*Projection) AddColumnShort ¶
func (m *Projection) AddColumnShort(colName string, vt value.ValueType)
func (*Projection) Equal ¶
func (m *Projection) Equal(s *Projection) bool
func (*Projection) FromPB ¶
func (m *Projection) FromPB(pb *ProjectionPb) *Projection
func (*Projection) ToPB ¶
func (m *Projection) ToPB() *ProjectionPb
type ProjectionPb ¶
type ProjectionPb struct { Distinct bool `protobuf:"varint,1,req,name=distinct" json:"distinct"` Final bool `protobuf:"varint,2,req,name=final" json:"final"` ColNames []string `protobuf:"bytes,3,rep,name=colNames" json:"colNames,omitempty"` Columns []*ResultColumnPb `protobuf:"bytes,4,rep,name=columns" json:"columns,omitempty"` XXX_unrecognized []byte `json:"-"` }
func (*ProjectionPb) Descriptor ¶
func (*ProjectionPb) Descriptor() ([]byte, []int)
func (*ProjectionPb) GetColNames ¶
func (m *ProjectionPb) GetColNames() []string
func (*ProjectionPb) GetColumns ¶
func (m *ProjectionPb) GetColumns() []*ResultColumnPb
func (*ProjectionPb) GetDistinct ¶
func (m *ProjectionPb) GetDistinct() bool
func (*ProjectionPb) GetFinal ¶
func (m *ProjectionPb) GetFinal() bool
func (*ProjectionPb) Marshal ¶
func (m *ProjectionPb) Marshal() (data []byte, err error)
func (*ProjectionPb) ProtoMessage ¶
func (*ProjectionPb) ProtoMessage()
func (*ProjectionPb) Reset ¶
func (m *ProjectionPb) Reset()
func (*ProjectionPb) Size ¶
func (m *ProjectionPb) Size() (n int)
func (*ProjectionPb) String ¶
func (m *ProjectionPb) String() string
func (*ProjectionPb) Unmarshal ¶
func (m *ProjectionPb) Unmarshal(data []byte) error
type ResultColumn ¶
type ResultColumn struct { Final bool // Is this part of final projection (ie, response) Name string // Original path/name for query field ColPos int // Ordinal position in sql (or partial sql) statement Col *Column // the original sql column Star bool // Was this a select * ?? As string // aliased Type value.ValueType // Data Type }
Result Column used in projection
func NewResultColumn ¶
func (*ResultColumn) Equal ¶
func (m *ResultColumn) Equal(s *ResultColumn) bool
func (*ResultColumn) SourceName ¶
func (m *ResultColumn) SourceName() string
The source column name
type ResultColumnPb ¶
type ResultColumnPb struct { Final *bool `protobuf:"varint,1,opt,name=final" json:"final,omitempty"` Name string `protobuf:"bytes,2,req,name=name" json:"name"` ColPos int32 `protobuf:"varint,3,req,name=colPos" json:"colPos"` Column *ColumnPb `protobuf:"bytes,4,opt,name=column" json:"column,omitempty"` Star *bool `protobuf:"varint,5,opt,name=star" json:"star,omitempty"` As string `protobuf:"bytes,6,req,name=as" json:"as"` ValueType int32 `protobuf:"varint,7,req,name=valueType" json:"valueType"` XXX_unrecognized []byte `json:"-"` }
func (*ResultColumnPb) Descriptor ¶
func (*ResultColumnPb) Descriptor() ([]byte, []int)
func (*ResultColumnPb) GetAs ¶
func (m *ResultColumnPb) GetAs() string
func (*ResultColumnPb) GetColPos ¶
func (m *ResultColumnPb) GetColPos() int32
func (*ResultColumnPb) GetColumn ¶
func (m *ResultColumnPb) GetColumn() *ColumnPb
func (*ResultColumnPb) GetFinal ¶
func (m *ResultColumnPb) GetFinal() bool
func (*ResultColumnPb) GetName ¶
func (m *ResultColumnPb) GetName() string
func (*ResultColumnPb) GetStar ¶
func (m *ResultColumnPb) GetStar() bool
func (*ResultColumnPb) GetValueType ¶
func (m *ResultColumnPb) GetValueType() int32
func (*ResultColumnPb) Marshal ¶
func (m *ResultColumnPb) Marshal() (data []byte, err error)
func (*ResultColumnPb) ProtoMessage ¶
func (*ResultColumnPb) ProtoMessage()
func (*ResultColumnPb) Reset ¶
func (m *ResultColumnPb) Reset()
func (*ResultColumnPb) Size ¶
func (m *ResultColumnPb) Size() (n int)
func (*ResultColumnPb) String ¶
func (m *ResultColumnPb) String() string
func (*ResultColumnPb) Unmarshal ¶
func (m *ResultColumnPb) Unmarshal(data []byte) error
type ResultColumns ¶
type ResultColumns []*ResultColumn
ResultColumns List of ResultColumns used to describe projection response columns
type SqlAlter ¶
type SqlAlter struct { Raw string // full original raw statement Identity string // identity to alter Tok lex.Token // ALTER [TABLE,VIEW,CONTINUOUSVIEW,TRIGGER] etc Cols []*DdlColumn // columns }
SqlAlter SQL ALTER statement
func (*SqlAlter) FingerPrint ¶
func (*SqlAlter) WriteDialect ¶
func (m *SqlAlter) WriteDialect(w expr.DialectWriter)
type SqlCommand ¶
type SqlCommand struct { Columns CommandColumns // can have multiple columns in command Identity string // Value expr.Node // // contains filtered or unexported fields }
SqlCommand is admin command such as "SET", "USE"
func (*SqlCommand) FingerPrint ¶
func (m *SqlCommand) FingerPrint(r rune) string
func (*SqlCommand) Keyword ¶
func (m *SqlCommand) Keyword() lex.TokenType
func (*SqlCommand) String ¶
func (m *SqlCommand) String() string
func (*SqlCommand) WriteDialect ¶
func (m *SqlCommand) WriteDialect(w expr.DialectWriter)
type SqlCreate ¶
type SqlCreate struct { Raw string // full original raw statement Identity string // identity of table, view, etc Tok lex.Token // CREATE [TABLE,VIEW,CONTINUOUSVIEW,TRIGGER] etc OrReplace bool // OR REPLACE IfNotExists bool // IF NOT EXISTS Cols []*DdlColumn // columns Engine map[string]interface{} With u.JsonHelper Select *SqlSelect }
SqlCreate SQL CREATE statement
func NewSqlCreate ¶
func NewSqlCreate() *SqlCreate
func (*SqlCreate) FingerPrint ¶
func (*SqlCreate) WriteDialect ¶
func (m *SqlCreate) WriteDialect(w expr.DialectWriter)
type SqlDelete ¶
SqlDelete SQL Delete Statement
func NewSqlDelete ¶
func NewSqlDelete() *SqlDelete
func (*SqlDelete) WriteDialect ¶
func (m *SqlDelete) WriteDialect(w expr.DialectWriter)
type SqlDescribe ¶
type SqlDescribe struct { Raw string // full original raw statement Identity string // Describe Tok lex.Token // Explain, Describe, Desc Stmt SqlStatement }
SQL Describe statement
func (*SqlDescribe) Keyword ¶
func (m *SqlDescribe) Keyword() lex.TokenType
func (*SqlDescribe) String ¶
func (m *SqlDescribe) String() string
func (*SqlDescribe) WriteDialect ¶
func (m *SqlDescribe) WriteDialect(w expr.DialectWriter)
type SqlDrop ¶
type SqlDrop struct { Raw string // full original raw statement Identity string // identity of table, view, etc Temp bool // Temp? Tok lex.Token // DROP [TEMP] [TABLE,VIEW,CONTINUOUSVIEW,TRIGGER] etc With u.JsonHelper }
SqlDrop SQL DROP statement
func NewSqlDrop ¶
func NewSqlDrop() *SqlDrop
func (*SqlDrop) FingerPrint ¶
func (*SqlDrop) WriteDialect ¶
func (m *SqlDrop) WriteDialect(w expr.DialectWriter)
type SqlInsert ¶
type SqlInsert struct { Table string // table name Columns Columns // Column Names Rows [][]*ValueColumn // Values to insert Select *SqlSelect // // contains filtered or unexported fields }
SqlInsert SQL Insert Statement
func NewSqlInsert ¶
func NewSqlInsert() *SqlInsert
func (*SqlInsert) ColumnNames ¶
func (*SqlInsert) RewriteAsPrepareable ¶
RewriteAsPrepareable rewite the insert as a ? substituteable query
INSERT INTO user (name) VALUES ("wonder-woman") -> INSERT INTO user (name) VALUES (?)
func (*SqlInsert) WriteDialect ¶
func (m *SqlInsert) WriteDialect(w expr.DialectWriter)
type SqlInto ¶
type SqlInto struct {
Table string
}
SqlInto INTO statement (select a,b,c from y INTO z)
func NewSqlInto ¶
func (*SqlInto) WriteDialect ¶
func (m *SqlInto) WriteDialect(w expr.DialectWriter)
type SqlSelect ¶
type SqlSelect struct { Db string // If provided a use "dbname" Raw string // full original raw statement Star bool // for select * from ... Distinct bool // Distinct flag? Columns Columns // An array (ordered) list of columns From []*SqlSource // From, Join Into *SqlInto // Into "table" Where *SqlWhere // Expr Node, or *SqlSelect Having expr.Node // Filter results GroupBy Columns OrderBy Columns Limit int Offset int Alias string // Non-Standard sql, alias/name of sql another way of expression Prepared Statement With u.JsonHelper // Non-Standard SQL for properties/config info, similar to Cassandra with, purse json // contains filtered or unexported fields }
SqlSelect SQL Select statement
func NewSqlSelect ¶
func NewSqlSelect() *SqlSelect
func ParseSqlSelect ¶
ParseSqlSelect parse a sql statement as SELECT (or else error)
func ParseSqlSelectResolver ¶
func ParseSqlSelectResolver(sqlQuery string, fr expr.FuncResolver) (*SqlSelect, error)
ParseSqlSelectResolver parse as SELECT using function resolver.
func SqlSelectFromPb ¶
func SqlSelectFromPb(pb *SqlSelectPb) *SqlSelect
SqlSelectFromPb take a protobuf select struct and conver to SqlSelect
func (*SqlSelect) AliasedColumns ¶
func (*SqlSelect) ColIndexes ¶
func (*SqlSelect) Equal ¶
func (m *SqlSelect) Equal(ss SqlStatement) bool
func (*SqlSelect) Finalize ¶
Finalize this Query plan by preparing sub-sources
ie we need to rewrite some things into sub-statements - we need to share the join expression across sources
func (*SqlSelect) FingerPrintID ¶
func (*SqlSelect) FromPB ¶
func (m *SqlSelect) FromPB(spb *SqlSelectPb) *SqlSelect
func (*SqlSelect) IsAggQuery ¶
func (*SqlSelect) RewriteAsRawSelect ¶
func (m *SqlSelect) RewriteAsRawSelect()
We are removing Column Aliases "user_id as uid"
as well as functions - used when we are going to defer projection, aggs
func (*SqlSelect) SetSystemQry ¶
func (m *SqlSelect) SetSystemQry()
func (*SqlSelect) ToPB ¶
func (m *SqlSelect) ToPB() *SqlSelectPb
func (*SqlSelect) ToPbStatement ¶
func (m *SqlSelect) ToPbStatement() *SqlStatementPb
func (*SqlSelect) UnAliasedColumns ¶
func (*SqlSelect) WriteDialect ¶
func (m *SqlSelect) WriteDialect(w expr.DialectWriter)
type SqlSelectPb ¶
type SqlSelectPb struct { Db string `protobuf:"bytes,1,req,name=db" json:"db"` Raw string `protobuf:"bytes,2,req,name=raw" json:"raw"` Star bool `protobuf:"varint,3,req,name=star" json:"star"` Distinct bool `protobuf:"varint,4,req,name=distinct" json:"distinct"` Columns []*ColumnPb `protobuf:"bytes,5,rep,name=columns" json:"columns,omitempty"` From []*SqlSourcePb `protobuf:"bytes,6,rep,name=from" json:"from,omitempty"` Into *string `protobuf:"bytes,7,opt,name=into" json:"into,omitempty"` Where *SqlWherePb `protobuf:"bytes,8,opt,name=where" json:"where,omitempty"` Having *expr.NodePb `protobuf:"bytes,9,opt,name=having" json:"having,omitempty"` GroupBy []*ColumnPb `protobuf:"bytes,11,rep,name=groupBy" json:"groupBy,omitempty"` OrderBy []*ColumnPb `protobuf:"bytes,10,rep,name=orderBy" json:"orderBy,omitempty"` Limit int32 `protobuf:"varint,12,opt,name=limit" json:"limit"` Offset int32 `protobuf:"varint,13,opt,name=offset" json:"offset"` Alias *string `protobuf:"bytes,14,opt,name=alias" json:"alias,omitempty"` Projection *ProjectionPb `protobuf:"bytes,15,opt,name=projection" json:"projection,omitempty"` IsAgg bool `protobuf:"varint,16,req,name=isAgg" json:"isAgg"` Finalized bool `protobuf:"varint,17,req,name=finalized" json:"finalized"` Schemaqry bool `protobuf:"varint,18,req,name=schemaqry" json:"schemaqry"` With []byte `protobuf:"bytes,19,opt,name=with" json:"with,omitempty"` XXX_unrecognized []byte `json:"-"` }
func SqlSelectToPb ¶
func SqlSelectToPb(m *SqlSelect) *SqlSelectPb
SqlSelectToPb Given a select statement lets convert it into a PB statement
func (*SqlSelectPb) Descriptor ¶
func (*SqlSelectPb) Descriptor() ([]byte, []int)
func (*SqlSelectPb) GetAlias ¶
func (m *SqlSelectPb) GetAlias() string
func (*SqlSelectPb) GetColumns ¶
func (m *SqlSelectPb) GetColumns() []*ColumnPb
func (*SqlSelectPb) GetDb ¶
func (m *SqlSelectPb) GetDb() string
func (*SqlSelectPb) GetDistinct ¶
func (m *SqlSelectPb) GetDistinct() bool
func (*SqlSelectPb) GetFinalized ¶
func (m *SqlSelectPb) GetFinalized() bool
func (*SqlSelectPb) GetFrom ¶
func (m *SqlSelectPb) GetFrom() []*SqlSourcePb
func (*SqlSelectPb) GetGroupBy ¶
func (m *SqlSelectPb) GetGroupBy() []*ColumnPb
func (*SqlSelectPb) GetHaving ¶
func (m *SqlSelectPb) GetHaving() *expr.NodePb
func (*SqlSelectPb) GetInto ¶
func (m *SqlSelectPb) GetInto() string
func (*SqlSelectPb) GetIsAgg ¶
func (m *SqlSelectPb) GetIsAgg() bool
func (*SqlSelectPb) GetLimit ¶
func (m *SqlSelectPb) GetLimit() int32
func (*SqlSelectPb) GetOffset ¶
func (m *SqlSelectPb) GetOffset() int32
func (*SqlSelectPb) GetOrderBy ¶
func (m *SqlSelectPb) GetOrderBy() []*ColumnPb
func (*SqlSelectPb) GetProjection ¶
func (m *SqlSelectPb) GetProjection() *ProjectionPb
func (*SqlSelectPb) GetRaw ¶
func (m *SqlSelectPb) GetRaw() string
func (*SqlSelectPb) GetSchemaqry ¶
func (m *SqlSelectPb) GetSchemaqry() bool
func (*SqlSelectPb) GetStar ¶
func (m *SqlSelectPb) GetStar() bool
func (*SqlSelectPb) GetWhere ¶
func (m *SqlSelectPb) GetWhere() *SqlWherePb
func (*SqlSelectPb) GetWith ¶
func (m *SqlSelectPb) GetWith() []byte
func (*SqlSelectPb) Marshal ¶
func (m *SqlSelectPb) Marshal() (data []byte, err error)
func (*SqlSelectPb) ProtoMessage ¶
func (*SqlSelectPb) ProtoMessage()
func (*SqlSelectPb) Reset ¶
func (m *SqlSelectPb) Reset()
func (*SqlSelectPb) Size ¶
func (m *SqlSelectPb) Size() (n int)
func (*SqlSelectPb) String ¶
func (m *SqlSelectPb) String() string
func (*SqlSelectPb) Unmarshal ¶
func (m *SqlSelectPb) Unmarshal(data []byte) error
type SqlShow ¶
type SqlShow struct { Raw string // full raw statement Db string // Database/Schema name Full bool // SHOW FULL TABLE FROM Scope string // {FULL, GLOBAL, SESSION} ShowType string // object type, [tables, columns, etc] From string // `table` or `schema`.`table` Identity string // `table` or `schema`.`table` Create bool CreateWhat string Where expr.Node Like expr.Node }
SqlShow SQL SHOW Statement
func (*SqlShow) WriteDialect ¶
func (m *SqlShow) WriteDialect(w expr.DialectWriter)
type SqlSource ¶
type SqlSource struct { Source *SqlSelect // Sql Select Source query, written by Rewrite Raw string // Raw Partial Query Name string // From Name (optional, empty if join, subselect) Alias string // From name aliased Schema string // FROM `schema`.`table` Op lex.TokenType // In, =, ON LeftOrRight lex.TokenType // Left, Right JoinType lex.TokenType // INNER, OUTER JoinExpr expr.Node // Join expression x.y = q.y SubQuery *SqlSelect // optional, Join/SubSelect statement // Plan Hints, move to a dedicated planner Seekable bool // contains filtered or unexported fields }
SqlSource is a table name, sub-query, or join as used in SELECT <columns> FROM <SQLSOURCE>
- SELECT .. FROM table_name
- SELECT .. from (select a,b,c from tableb)
- SELECT .. FROM tablex INNER JOIN ...
func NewSqlSource ¶
func SqlSourceFromPb ¶
func SqlSourceFromPb(pb *SqlSourcePb) *SqlSource
func (*SqlSource) BuildColIndex ¶
func (*SqlSource) ColumnPositions ¶
Get a list of Column names to position
func (*SqlSource) FromPB ¶
func (m *SqlSource) FromPB(n *SqlSourcePb) *SqlSource
func (*SqlSource) JoinNodes ¶
We need to be able to rewrite statements to convert a stmt such as:
FROM users AS u INNER JOIN orders AS o ON u.user_id = o.user_id
So that we can evaluate the Join Key on left/right in this case, it is simple, just
=> user_id
or this one:
FROM users AS u INNER JOIN orders AS o ON LOWER(u.email) = LOWER(o.email) => LOWER(user_id)
func (*SqlSource) Rewrite ¶
Rewrite this Source to act as a stand-alone query to backend @parentStmt = the parent statement that this a partial source to
func (*SqlSource) SourceName ¶
func (*SqlSource) ToPB ¶
func (m *SqlSource) ToPB() *SqlSourcePb
func (*SqlSource) UnAliasedColumns ¶
Get a list of Un-Aliased Columns, ie columns with column
names that have NOT yet been aliased
func (*SqlSource) WriteDialect ¶
func (m *SqlSource) WriteDialect(w expr.DialectWriter)
type SqlSourcePb ¶
type SqlSourcePb struct { Final bool `protobuf:"varint,1,opt,name=final" json:"final"` AliasInner *string `protobuf:"bytes,2,opt,name=aliasInner" json:"aliasInner,omitempty"` Columns []*ColumnPb `protobuf:"bytes,3,rep,name=columns" json:"columns,omitempty"` ColIndex []KvInt `protobuf:"bytes,4,rep,name=colIndex" json:"colIndex"` JoinNodes []*expr.NodePb `protobuf:"bytes,5,rep,name=joinNodes" json:"joinNodes,omitempty"` Source *SqlSelectPb `protobuf:"bytes,6,opt,name=source" json:"source,omitempty"` Raw string `protobuf:"bytes,7,opt,name=raw" json:"raw"` Name string `protobuf:"bytes,8,opt,name=name" json:"name"` Alias string `protobuf:"bytes,9,opt,name=alias" json:"alias"` Op int32 `protobuf:"varint,10,req,name=op" json:"op"` LeftOrRight int32 `protobuf:"varint,11,req,name=leftOrRight" json:"leftOrRight"` JoinType int32 `protobuf:"varint,12,req,name=joinType" json:"joinType"` JoinExpr *expr.NodePb `protobuf:"bytes,13,opt,name=joinExpr" json:"joinExpr,omitempty"` SubQuery *SqlSelectPb `protobuf:"bytes,14,opt,name=subQuery" json:"subQuery,omitempty"` Seekable bool `protobuf:"varint,15,opt,name=seekable" json:"seekable"` XXX_unrecognized []byte `json:"-"` }
func (*SqlSourcePb) Descriptor ¶
func (*SqlSourcePb) Descriptor() ([]byte, []int)
func (*SqlSourcePb) GetAlias ¶
func (m *SqlSourcePb) GetAlias() string
func (*SqlSourcePb) GetAliasInner ¶
func (m *SqlSourcePb) GetAliasInner() string
func (*SqlSourcePb) GetColIndex ¶
func (m *SqlSourcePb) GetColIndex() []KvInt
func (*SqlSourcePb) GetColumns ¶
func (m *SqlSourcePb) GetColumns() []*ColumnPb
func (*SqlSourcePb) GetFinal ¶
func (m *SqlSourcePb) GetFinal() bool
func (*SqlSourcePb) GetJoinExpr ¶
func (m *SqlSourcePb) GetJoinExpr() *expr.NodePb
func (*SqlSourcePb) GetJoinNodes ¶
func (m *SqlSourcePb) GetJoinNodes() []*expr.NodePb
func (*SqlSourcePb) GetJoinType ¶
func (m *SqlSourcePb) GetJoinType() int32
func (*SqlSourcePb) GetLeftOrRight ¶
func (m *SqlSourcePb) GetLeftOrRight() int32
func (*SqlSourcePb) GetName ¶
func (m *SqlSourcePb) GetName() string
func (*SqlSourcePb) GetOp ¶
func (m *SqlSourcePb) GetOp() int32
func (*SqlSourcePb) GetRaw ¶
func (m *SqlSourcePb) GetRaw() string
func (*SqlSourcePb) GetSeekable ¶
func (m *SqlSourcePb) GetSeekable() bool
func (*SqlSourcePb) GetSource ¶
func (m *SqlSourcePb) GetSource() *SqlSelectPb
func (*SqlSourcePb) GetSubQuery ¶
func (m *SqlSourcePb) GetSubQuery() *SqlSelectPb
func (*SqlSourcePb) Marshal ¶
func (m *SqlSourcePb) Marshal() (data []byte, err error)
func (*SqlSourcePb) ProtoMessage ¶
func (*SqlSourcePb) ProtoMessage()
func (*SqlSourcePb) Reset ¶
func (m *SqlSourcePb) Reset()
func (*SqlSourcePb) Size ¶
func (m *SqlSourcePb) Size() (n int)
func (*SqlSourcePb) String ¶
func (m *SqlSourcePb) String() string
func (*SqlSourcePb) Unmarshal ¶
func (m *SqlSourcePb) Unmarshal(data []byte) error
type SqlSourceStatement ¶
type SqlSourceStatement interface { // string representation of Node, AST parseable back to itself String() string // Write out this statement in a specific dialect WriteDialect(w expr.DialectWriter) // SQL Keyword for this statement Keyword() lex.TokenType }
SqlSourceStatement interface, to define the subselect/join-types Join, SubSelect, From
type SqlStatement ¶
type SqlStatement interface { // string representation of Node, AST parseable back to itself String() string // Write out this statement in a specific dialect WriteDialect(w expr.DialectWriter) // SQL keyword (select, insert, etc) Keyword() lex.TokenType }
SqlStatement interface, to define the sql statement Select, Insert, Update, Delete, Command, Show, Describe etc
func ParseSql ¶
func ParseSql(sqlQuery string) (SqlStatement, error)
ParseSql Parses SqlStatement and returns a statement or error does not parse more than one statement
func ParseSqlStatements ¶
func ParseSqlStatements(sqlQuery string) ([]SqlStatement, error)
ParseSqlStatements into array of SQL Statements
func SqlFromPb ¶
func SqlFromPb(pb []byte) (SqlStatement, error)
SqlFromPb Create a sql statement from pb
type SqlStatementPb ¶
type SqlStatementPb struct { Select *SqlSelectPb `protobuf:"bytes,1,opt,name=select" json:"select,omitempty"` Source *SqlSourcePb `protobuf:"bytes,2,opt,name=source" json:"source,omitempty"` Projection *ProjectionPb `protobuf:"bytes,4,opt,name=projection" json:"projection,omitempty"` XXX_unrecognized []byte `json:"-"` }
The generic SqlStatement, must be exactly one of these types
func (*SqlStatementPb) Descriptor ¶
func (*SqlStatementPb) Descriptor() ([]byte, []int)
func (*SqlStatementPb) GetProjection ¶
func (m *SqlStatementPb) GetProjection() *ProjectionPb
func (*SqlStatementPb) GetSelect ¶
func (m *SqlStatementPb) GetSelect() *SqlSelectPb
func (*SqlStatementPb) GetSource ¶
func (m *SqlStatementPb) GetSource() *SqlSourcePb
func (*SqlStatementPb) Marshal ¶
func (m *SqlStatementPb) Marshal() (data []byte, err error)
func (*SqlStatementPb) ProtoMessage ¶
func (*SqlStatementPb) ProtoMessage()
func (*SqlStatementPb) Reset ¶
func (m *SqlStatementPb) Reset()
func (*SqlStatementPb) Size ¶
func (m *SqlStatementPb) Size() (n int)
func (*SqlStatementPb) String ¶
func (m *SqlStatementPb) String() string
func (*SqlStatementPb) Unmarshal ¶
func (m *SqlStatementPb) Unmarshal(data []byte) error
type SqlTokenPager ¶
type SqlTokenPager struct { *expr.LexTokenPager // contains filtered or unexported fields }
TokenPager is responsible for determining end of current tree (column, etc)
func NewSqlTokenPager ¶
func NewSqlTokenPager(l *lex.Lexer) *SqlTokenPager
func (*SqlTokenPager) ClauseEnd ¶
func (m *SqlTokenPager) ClauseEnd() bool
func (*SqlTokenPager) IsEnd ¶
func (m *SqlTokenPager) IsEnd() bool
type SqlUpdate ¶
type SqlUpdate struct { Values map[string]*ValueColumn Where *SqlWhere Table string }
SqlUpdate SQL Update Statement
func NewSqlUpdate ¶
func NewSqlUpdate() *SqlUpdate
func (*SqlUpdate) WriteDialect ¶
func (m *SqlUpdate) WriteDialect(w expr.DialectWriter)
type SqlUpsert ¶
type SqlUpsert struct { Columns Columns Rows [][]*ValueColumn Values map[string]*ValueColumn Where *SqlWhere Table string }
SqlUpsert SQL Upsert Statement
func NewSqlUpsert ¶
func NewSqlUpsert() *SqlUpsert
func (*SqlUpsert) WriteDialect ¶
func (m *SqlUpsert) WriteDialect(w expr.DialectWriter)
type SqlWhere ¶
type SqlWhere struct { // Either Op + Source exists Op lex.TokenType // (In|=|ON) for Select Clauses operators Source *SqlSelect // IN (SELECT a,b,c from z) // OR expr but not both Expr expr.Node // x = y AND q > 5 }
SqlWhere WHERE is select stmt, or set of expressions - WHERE x in (select name from q) - WHERE x = y - WHERE x = y AND z = q - WHERE tolower(x) IN (select name from q)
func NewSqlWhere ¶
func SqlWhereFromPb ¶
func SqlWhereFromPb(pb *SqlWherePb) *SqlWhere
func (*SqlWhere) WriteDialect ¶
func (m *SqlWhere) WriteDialect(w expr.DialectWriter)
type SqlWherePb ¶
type SqlWherePb struct { Op int32 `protobuf:"varint,1,req,name=op" json:"op"` Source *SqlSelectPb `protobuf:"bytes,2,opt,name=source" json:"source,omitempty"` Expr *expr.NodePb `protobuf:"bytes,3,opt,name=Expr,json=expr" json:"Expr,omitempty"` XXX_unrecognized []byte `json:"-"` }
func SqlWhereToPb ¶
func SqlWhereToPb(m *SqlWhere) *SqlWherePb
func (*SqlWherePb) Descriptor ¶
func (*SqlWherePb) Descriptor() ([]byte, []int)
func (*SqlWherePb) GetExpr ¶
func (m *SqlWherePb) GetExpr() *expr.NodePb
func (*SqlWherePb) GetOp ¶
func (m *SqlWherePb) GetOp() int32
func (*SqlWherePb) GetSource ¶
func (m *SqlWherePb) GetSource() *SqlSelectPb
func (*SqlWherePb) Marshal ¶
func (m *SqlWherePb) Marshal() (data []byte, err error)
func (*SqlWherePb) ProtoMessage ¶
func (*SqlWherePb) ProtoMessage()
func (*SqlWherePb) Reset ¶
func (m *SqlWherePb) Reset()
func (*SqlWherePb) Size ¶
func (m *SqlWherePb) Size() (n int)
func (*SqlWherePb) String ¶
func (m *SqlWherePb) String() string
func (*SqlWherePb) Unmarshal ¶
func (m *SqlWherePb) Unmarshal(data []byte) error
type Sqlbridge ¶
type Sqlbridge struct { *SqlTokenPager // contains filtered or unexported fields }
Sqlbridge generic SQL parser evaluates should be sufficient for most sql compatible languages