Documentation ¶
Overview ¶
Package plantest contains utilities for testing each query planning phase
Index ¶
- Variables
- func CompareLogicalPlanNodes(p, q plan.Node) error
- func CompareLogicalPlans(p, q *plan.Spec) error
- func ComparePhysicalPlanNodes(p, q plan.Node) error
- func ComparePlans(p, q *plan.Spec, f func(p, q plan.Node) error) error
- func ComparePlansShallow(p, q *plan.Spec) error
- func CreateLogicalMockNode(id string) *plan.LogicalNode
- func CreatePhysicalMockNode(id string) *plan.PhysicalPlanNode
- func CreatePhysicalNode(id plan.NodeID, spec plan.PhysicalProcedureSpec) *plan.PhysicalPlanNode
- func CreatePlanSpec(ps *PlanSpec) *plan.Spec
- func LogicalRuleTestHelper(t *testing.T, tc *RuleTestCase, options ...cmp.Option)
- func PhysicalRuleTestHelper(t *testing.T, tc *RuleTestCase, options ...cmp.Option)
- type CreateCycleRule
- type FunctionRule
- type MockProcedureSpec
- type MultiRootRule
- type PlanSpec
- type RuleTestCase
- type SimpleRule
- type SmashPlanRule
Constants ¶
This section is empty.
Variables ¶
var CmpOptions = append( semantictest.CmpOptions, cmp.AllowUnexported(operation.Spec{}), cmp.AllowUnexported(universe.JoinOpSpec{}), cmpopts.IgnoreUnexported(operation.Spec{}), cmpopts.IgnoreUnexported(universe.JoinOpSpec{}), cmp.AllowUnexported(kafka.ToKafkaProcedureSpec{}), cmpopts.IgnoreUnexported(kafka.ToKafkaProcedureSpec{}), valuestest.ScopeTransformer, )
CmpOptions are the options needed to compare plan.ProcedureSpecs inside plan.Spec.
Functions ¶
func CompareLogicalPlanNodes ¶
CompareLogicalPlanNodes is a comparator function for LogicalPlanNodes
func CompareLogicalPlans ¶
CompareLogicalPlans compares two logical plans.
func ComparePhysicalPlanNodes ¶
ComparePhysicalPlanNodes is a comparator function for PhysicalPlanNodes
func ComparePlans ¶
ComparePlans compares two query plans using an arbitrary comparator function f
func ComparePlansShallow ¶
ComparePlansShallow Compares the two specs, but only compares the metadata and the types of each node. Individual fields of procedure specs are not compared.
func CreateLogicalMockNode ¶
func CreateLogicalMockNode(id string) *plan.LogicalNode
func CreatePhysicalMockNode ¶
func CreatePhysicalMockNode(id string) *plan.PhysicalPlanNode
func CreatePhysicalNode ¶
func CreatePhysicalNode(id plan.NodeID, spec plan.PhysicalProcedureSpec) *plan.PhysicalPlanNode
func CreatePlanSpec ¶
func LogicalRuleTestHelper ¶
func LogicalRuleTestHelper(t *testing.T, tc *RuleTestCase, options ...cmp.Option)
LogicalRuleTestHelper will run a rule test case.
func PhysicalRuleTestHelper ¶
func PhysicalRuleTestHelper(t *testing.T, tc *RuleTestCase, options ...cmp.Option)
PhysicalRuleTestHelper will run a rule test case.
Types ¶
type CreateCycleRule ¶
type CreateCycleRule struct { Node plan.Node Kind plan.ProcedureKind }
CreateCycleRule creates a cycle between the given `Node` and its predecessor. It creates exactly one cycle. After the rule is triggered once, it won't have any effect later. This rule breaks the integrity of the plan. If `Kind` is specified, it takes precedence over `Node`, and the rule will use it to match.
func (CreateCycleRule) Name ¶
func (CreateCycleRule) Name() string
func (CreateCycleRule) Pattern ¶
func (ccr CreateCycleRule) Pattern() plan.Pattern
type FunctionRule ¶
type FunctionRule struct {
RewriteFn func(ctx context.Context, node plan.Node) (plan.Node, bool, error)
}
FunctionRule is a simple rule intended to invoke a Rewrite function.
func (*FunctionRule) Name ¶
func (fr *FunctionRule) Name() string
func (*FunctionRule) Pattern ¶
func (fr *FunctionRule) Pattern() plan.Pattern
type MockProcedureSpec ¶
type MockProcedureSpec = spec.MockProcedureSpec
type MultiRootRule ¶
MultiRootRule matches a set of plan nodes at the root and stores the NodeIDs of nodes it has visited in SeenNodes.
func (*MultiRootRule) Name ¶
func (sr *MultiRootRule) Name() string
func (*MultiRootRule) Pattern ¶
func (sr *MultiRootRule) Pattern() plan.Pattern
type RuleTestCase ¶
type RuleTestCase struct { Name string Context context.Context Rules []plan.Rule Before *PlanSpec After *PlanSpec NoChange bool SkipValidation bool ValidateError error }
RuleTestCase allows for concise creation of test cases that exercise rules
type SimpleRule ¶
SimpleRule is a simple rule whose pattern matches any plan node and just stores the NodeIDs of nodes it has visited in SeenNodes.
func (*SimpleRule) Name ¶
func (sr *SimpleRule) Name() string
func (*SimpleRule) Pattern ¶
func (sr *SimpleRule) Pattern() plan.Pattern
type SmashPlanRule ¶
SmashPlanRule adds an `Intruder` as predecessor of the given `Node` without marking it as successor of it. It breaks the integrity of the plan. If `Kind` is specified, it takes precedence over `Node`, and the rule will use it to match.
func (SmashPlanRule) Name ¶
func (SmashPlanRule) Name() string
func (SmashPlanRule) Pattern ¶
func (spp SmashPlanRule) Pattern() plan.Pattern