Documentation
¶
Index ¶
- func AssertFunc(b bool, errInfo string)
- func AssertPlan(ctx context.Context, sql string, pattern *MatchPattern) error
- func Insert(ctx context.Context, aliases UnorderedMap[string, string], k, v string) error
- func MergeAliases(ctx context.Context, aliases1, aliases2 UnorderedMap[string, string]) error
- func SimpleMatchMatchers(pattern *MatchPattern, node *plan2.Node) bool
- func StringsEqual(a, b []string) bool
- func VarRefsEqual(a, b []VarRef) bool
- type AggrFuncMatcher
- type AggrPair
- type AliasMatcher
- type AssertConfig
- type AssignPair
- type AssignedSymbolsMatcher
- type ColumnRef
- type Domain
- type ExprChecker
- type ExprMatcher
- type GetFunc
- type JoinMatcher
- type MatchPattern
- func TAggr(aggrs UnorderedMap[string, *AggrFuncMatcher], children ...*MatchPattern) *MatchPattern
- func TAny(children ...*MatchPattern) *MatchPattern
- func TAnyNot(nodeType plan2.Node_NodeType, children ...*MatchPattern) *MatchPattern
- func TAnyTree(children ...*MatchPattern) *MatchPattern
- func TJoin(joinTyp plan2.Node_JoinType, onConds []string, filters []string, ...) *MatchPattern
- func TNode(nodeType plan2.Node_NodeType, children ...*MatchPattern) *MatchPattern
- func TOutput(outputs []string, child *MatchPattern) *MatchPattern
- func TOutputWithoutOutputs(child *MatchPattern) *MatchPattern
- func TProject(assigns UnorderedMap[string, *ExprMatcher], child *MatchPattern) *MatchPattern
- func TProjectWithoutAssignments(child *MatchPattern) *MatchPattern
- func TStrictOutput(outputs []string, child *MatchPattern) *MatchPattern
- func TStrictProject(assigns UnorderedMap[string, *ExprMatcher], child *MatchPattern) *MatchPattern
- func TStrictTableScan(tableName string, colRefs UnorderedMap[string, string]) *MatchPattern
- func TTableScan(tableName string, colRefs UnorderedMap[string, string]) *MatchPattern
- func TTableScanWithoutColRef(tableName string) *MatchPattern
- func (pattern *MatchPattern) AddColRefs(name string, refs UnorderedMap[string, string]) *MatchPattern
- func (pattern *MatchPattern) IsEnd() bool
- func (pattern *MatchPattern) MatchAnyTree() *MatchPattern
- func (pattern *MatchPattern) String() string
- func (pattern *MatchPattern) With(matcher Matcher) *MatchPattern
- func (pattern *MatchPattern) WithAlias(alias string, matcher RValueMatcher) *MatchPattern
- func (pattern *MatchPattern) WithExactAssignedOutputs(expectedAliases []RValueMatcher) *MatchPattern
- func (pattern *MatchPattern) WithExactAssignments(expectedAliases []RValueMatcher) *MatchPattern
- func (pattern *MatchPattern) WithExactOutputs(outputs ...string) *MatchPattern
- func (pattern *MatchPattern) WithOutputs(aliases ...string) *MatchPattern
- type MatchResult
- func DeepMatch(ctx context.Context, node *plan2.Node, pattern *MatchPattern, ...) (*MatchResult, error)
- func FailMatched() *MatchResult
- func Match(ctx context.Context, nodes []*plan2.Node, node *plan2.Node, ...) (*MatchResult, error)
- func MatchChildren(ctx context.Context, nodes []*plan2.Node, node *plan2.Node, ...) (*MatchResult, error)
- func MatchLeaf(ctx context.Context, node *plan2.Node, pattern *MatchPattern, ...) (*MatchResult, error)
- func MatchSteps(ctx context.Context, query *plan2.Query, pattern *MatchPattern) (*MatchResult, error)
- func Matched() *MatchResult
- func MatchedWithAlias(alias, ref string) *MatchResult
- func MatchedWithAliases(aliases UnorderedMap[string, string]) *MatchResult
- func NewMatchResult(isMatch bool, retAliases UnorderedMap[string, string]) *MatchResult
- type Matcher
- type MatchingState
- type NodeMatcher
- type OutputMatcher
- type Pair
- type RValueMatcher
- type StringPair
- type SymbolsMatcher
- type TableScanMatcher
- type UnorderedMap
- func MergeAliasesReturnNew(ctx context.Context, aliases1, aliases2 UnorderedMap[string, string]) (UnorderedMap[string, string], error)
- func NewAggrMap(pairs ...AggrPair) UnorderedMap[string, *AggrFuncMatcher]
- func NewAssignMap(pairs ...AssignPair) UnorderedMap[string, *ExprMatcher]
- func NewStringMap(pairs ...StringPair) UnorderedMap[string, string]
- type ValuesMatcher
- type VarRef
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertFunc ¶
func AssertPlan ¶
func AssertPlan(ctx context.Context, sql string, pattern *MatchPattern) error
func MergeAliases ¶
func SimpleMatchMatchers ¶
func SimpleMatchMatchers(pattern *MatchPattern, node *plan2.Node) bool
func StringsEqual ¶
func VarRefsEqual ¶
Types ¶
type AggrFuncMatcher ¶
func NewAggrFuncMatcher ¶
func NewAggrFuncMatcher(s string) *AggrFuncMatcher
func (*AggrFuncMatcher) GetAssignedVar ¶
func (matcher *AggrFuncMatcher) GetAssignedVar(node *plan2.Node, aliases UnorderedMap[string, string]) (*VarRef, error)
func (*AggrFuncMatcher) String ¶
func (matcher *AggrFuncMatcher) String() string
type AggrPair ¶
type AggrPair Pair[string, *AggrFuncMatcher]
func NewAggrPair ¶
func NewAggrPair(k string, v *AggrFuncMatcher) AggrPair
type AliasMatcher ¶
type AliasMatcher struct {
Alias string
Matcher RValueMatcher
}
func (*AliasMatcher) DeepMatch ¶
func (matcher *AliasMatcher) DeepMatch(ctx context.Context, node *plan.Node, aliases UnorderedMap[string, string]) (*MatchResult, error)
func (*AliasMatcher) SimpleMatch ¶
func (matcher *AliasMatcher) SimpleMatch(node *plan.Node) bool
func (*AliasMatcher) String ¶
func (matcher *AliasMatcher) String() string
type AssertConfig ¶
type AssertConfig struct {
}
type AssignPair ¶
type AssignPair Pair[string, *ExprMatcher]
func NewAssignPair ¶
func NewAssignPair(k string, v *ExprMatcher) AssignPair
type AssignedSymbolsMatcher ¶
type AssignedSymbolsMatcher struct {
GetFunc GetFunc
ExpectedMatchers []RValueMatcher
}
func (*AssignedSymbolsMatcher) DeepMatch ¶
func (matcher *AssignedSymbolsMatcher) DeepMatch(ctx context.Context, node *plan.Node, aliases UnorderedMap[string, string]) (*MatchResult, error)
func (*AssignedSymbolsMatcher) SimpleMatch ¶
func (matcher *AssignedSymbolsMatcher) SimpleMatch(node *plan.Node) bool
func (*AssignedSymbolsMatcher) String ¶
func (matcher *AssignedSymbolsMatcher) String() string
type ColumnRef ¶
func (*ColumnRef) GetAssignedVar ¶
type ExprChecker ¶
type ExprChecker struct {
Aliases UnorderedMap[string, string]
}
type ExprMatcher ¶
func NewExprMatcher ¶
func NewExprMatcher(sql string) *ExprMatcher
func TExpr ¶
func TExpr(e string) *ExprMatcher
func (*ExprMatcher) GetAssignedVar ¶
func (matcher *ExprMatcher) GetAssignedVar(node *plan2.Node, aliases UnorderedMap[string, string]) (*VarRef, error)
func (*ExprMatcher) String ¶
func (matcher *ExprMatcher) String() string
type JoinMatcher ¶
type JoinMatcher struct {
JoinTyp plan2.Node_JoinType
OnCondsStr []string
OnConds []tree.Expr
FiltersStr []string
Filters []tree.Expr
}
func NewJoinMatcher ¶
func NewJoinMatcher(joinType plan2.Node_JoinType, conds []string, filters []string) *JoinMatcher
func (*JoinMatcher) DeepMatch ¶
func (matcher *JoinMatcher) DeepMatch(ctx context.Context, node *plan2.Node, aliases UnorderedMap[string, string]) (*MatchResult, error)
func (*JoinMatcher) SimpleMatch ¶
func (matcher *JoinMatcher) SimpleMatch(node *plan2.Node) bool
func (*JoinMatcher) String ¶
func (matcher *JoinMatcher) String() string
type MatchPattern ¶
type MatchPattern struct {
Matchers []Matcher //matchers for components in Node
Children []*MatchPattern // children pattern of children nodes
AnyTree bool
}
MatchPattern denotes the structure pattern that the Plan should have.
func TAggr ¶
func TAggr(aggrs UnorderedMap[string, *AggrFuncMatcher], children ...*MatchPattern) *MatchPattern
func TAny ¶
func TAny(children ...*MatchPattern) *MatchPattern
TAny yields a pattern without designated node type
func TAnyNot ¶
func TAnyNot(nodeType plan2.Node_NodeType, children ...*MatchPattern) *MatchPattern
func TAnyTree ¶
func TAnyTree(children ...*MatchPattern) *MatchPattern
TAnyTree denotes children tree matches the patterns
func TJoin ¶
func TJoin(joinTyp plan2.Node_JoinType, onConds []string, filters []string, left, right *MatchPattern) *MatchPattern
func TNode ¶
func TNode(nodeType plan2.Node_NodeType, children ...*MatchPattern) *MatchPattern
func TOutput ¶
func TOutput(outputs []string, child *MatchPattern) *MatchPattern
func TOutputWithoutOutputs ¶
func TOutputWithoutOutputs(child *MatchPattern) *MatchPattern
func TProject ¶
func TProject(assigns UnorderedMap[string, *ExprMatcher], child *MatchPattern) *MatchPattern
func TProjectWithoutAssignments ¶
func TProjectWithoutAssignments(child *MatchPattern) *MatchPattern
func TStrictOutput ¶
func TStrictOutput(outputs []string, child *MatchPattern) *MatchPattern
func TStrictProject ¶
func TStrictProject(assigns UnorderedMap[string, *ExprMatcher], child *MatchPattern) *MatchPattern
func TStrictTableScan ¶
func TStrictTableScan(tableName string, colRefs UnorderedMap[string, string]) *MatchPattern
func TTableScan ¶
func TTableScan(tableName string, colRefs UnorderedMap[string, string]) *MatchPattern
func TTableScanWithoutColRef ¶
func TTableScanWithoutColRef(tableName string) *MatchPattern
func (*MatchPattern) AddColRefs ¶
func (pattern *MatchPattern) AddColRefs(name string, refs UnorderedMap[string, string]) *MatchPattern
func (*MatchPattern) IsEnd ¶
func (pattern *MatchPattern) IsEnd() bool
func (*MatchPattern) MatchAnyTree ¶
func (pattern *MatchPattern) MatchAnyTree() *MatchPattern
func (*MatchPattern) String ¶
func (pattern *MatchPattern) String() string
func (*MatchPattern) With ¶
func (pattern *MatchPattern) With(matcher Matcher) *MatchPattern
func (*MatchPattern) WithAlias ¶
func (pattern *MatchPattern) WithAlias(alias string, matcher RValueMatcher) *MatchPattern
func (*MatchPattern) WithExactAssignedOutputs ¶
func (pattern *MatchPattern) WithExactAssignedOutputs(expectedAliases []RValueMatcher) *MatchPattern
func (*MatchPattern) WithExactAssignments ¶
func (pattern *MatchPattern) WithExactAssignments(expectedAliases []RValueMatcher) *MatchPattern
func (*MatchPattern) WithExactOutputs ¶
func (pattern *MatchPattern) WithExactOutputs(outputs ...string) *MatchPattern
func (*MatchPattern) WithOutputs ¶
func (pattern *MatchPattern) WithOutputs(aliases ...string) *MatchPattern
type MatchResult ¶
type MatchResult struct {
IsMatch bool
RetAliases UnorderedMap[string, string]
}
func DeepMatch ¶
func DeepMatch( ctx context.Context, node *plan2.Node, pattern *MatchPattern, aliases UnorderedMap[string, string]) (*MatchResult, error)
func FailMatched ¶
func FailMatched() *MatchResult
func Match ¶
func Match(ctx context.Context, nodes []*plan2.Node, node *plan2.Node, pattern *MatchPattern) (*MatchResult, error)
func MatchChildren ¶
func MatchChildren(ctx context.Context, nodes []*plan2.Node, node *plan2.Node, state *MatchingState) (*MatchResult, error)
func MatchLeaf ¶
func MatchLeaf(ctx context.Context, node *plan2.Node, pattern *MatchPattern, states []*MatchingState) (*MatchResult, error)
func MatchSteps ¶
func MatchSteps(ctx context.Context, query *plan2.Query, pattern *MatchPattern) (*MatchResult, error)
func Matched ¶
func Matched() *MatchResult
func MatchedWithAlias ¶
func MatchedWithAlias(alias, ref string) *MatchResult
func MatchedWithAliases ¶
func MatchedWithAliases(aliases UnorderedMap[string, string]) *MatchResult
func NewMatchResult ¶
func NewMatchResult(isMatch bool, retAliases UnorderedMap[string, string]) *MatchResult
func (*MatchResult) String ¶
func (mr *MatchResult) String() string
type Matcher ¶
type Matcher interface {
// SimpleMatch check the intuitive properties about Node like type, datatype, etc.
SimpleMatch(*plan2.Node) bool
// DeepMatch check the internal structure about Node
DeepMatch(context.Context, *plan2.Node, UnorderedMap[string, string]) (*MatchResult, error)
String() string
}
type MatchingState ¶
type MatchingState struct {
Patterns []*MatchPattern
}
func SimpleMatch ¶
func SimpleMatch(pattern *MatchPattern, node *plan2.Node) []*MatchingState
func (*MatchingState) IsEnd ¶
func (state *MatchingState) IsEnd() bool
type NodeMatcher ¶
type NodeMatcher struct {
NodeType plan2.Node_NodeType
Not bool
}
func (*NodeMatcher) DeepMatch ¶
func (matcher *NodeMatcher) DeepMatch(ctx context.Context, node *plan.Node, aliases UnorderedMap[string, string]) (*MatchResult, error)
func (*NodeMatcher) SimpleMatch ¶
func (matcher *NodeMatcher) SimpleMatch(node *plan2.Node) bool
func (*NodeMatcher) String ¶
func (matcher *NodeMatcher) String() string
type OutputMatcher ¶
type OutputMatcher struct {
Aliases []string
}
func (*OutputMatcher) DeepMatch ¶
func (matcher *OutputMatcher) DeepMatch(ctx context.Context, node *plan.Node, aliases UnorderedMap[string, string]) (*MatchResult, error)
func (*OutputMatcher) SimpleMatch ¶
func (matcher *OutputMatcher) SimpleMatch(node *plan.Node) bool
func (*OutputMatcher) String ¶
func (matcher *OutputMatcher) String() string
type RValueMatcher ¶
type RValueMatcher interface {
GetAssignedVar(*plan2.Node, UnorderedMap[string, string]) (*VarRef, error)
String() string
}
func TColumnRef ¶
func TColumnRef(tableName, colName string) RValueMatcher
type StringPair ¶
func NewStringPair ¶
func NewStringPair(k, v string) StringPair
type SymbolsMatcher ¶
func (*SymbolsMatcher) DeepMatch ¶
func (matcher *SymbolsMatcher) DeepMatch(ctx context.Context, node *plan.Node, aliases UnorderedMap[string, string]) (*MatchResult, error)
func (*SymbolsMatcher) SimpleMatch ¶
func (matcher *SymbolsMatcher) SimpleMatch(node *plan.Node) bool
func (*SymbolsMatcher) String ¶
func (matcher *SymbolsMatcher) String() string
type TableScanMatcher ¶
type TableScanMatcher struct {
TableName string
Constraint UnorderedMap[string, *Domain]
}
func (*TableScanMatcher) DeepMatch ¶
func (matcher *TableScanMatcher) DeepMatch(ctx context.Context, node *plan.Node, aliases UnorderedMap[string, string]) (*MatchResult, error)
func (*TableScanMatcher) SimpleMatch ¶
func (matcher *TableScanMatcher) SimpleMatch(node *plan.Node) bool
func (*TableScanMatcher) String ¶
func (matcher *TableScanMatcher) String() string
type UnorderedMap ¶
func MergeAliasesReturnNew ¶
func MergeAliasesReturnNew(ctx context.Context, aliases1, aliases2 UnorderedMap[string, string]) (UnorderedMap[string, string], error)
func NewAggrMap ¶
func NewAggrMap(pairs ...AggrPair) UnorderedMap[string, *AggrFuncMatcher]
func NewAssignMap ¶
func NewAssignMap(pairs ...AssignPair) UnorderedMap[string, *ExprMatcher]
func NewStringMap ¶
func NewStringMap(pairs ...StringPair) UnorderedMap[string, string]
func (UnorderedMap[KT, VT]) Count ¶
func (umap UnorderedMap[KT, VT]) Count(k KT) int
func (UnorderedMap[KT, VT]) Find ¶
func (umap UnorderedMap[KT, VT]) Find(k KT) (ok bool, v VT)
func (UnorderedMap[KT, VT]) Insert ¶
func (umap UnorderedMap[KT, VT]) Insert(k KT, v VT)
func (UnorderedMap[KT, VT]) Size ¶
func (umap UnorderedMap[KT, VT]) Size() int
type ValuesMatcher ¶
type ValuesMatcher struct {
}
Click to show internal directories.
Click to hide internal directories.