plantest

package
v0.187.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package plantest contains utilities for testing each query planning phase

Index

Constants

This section is empty.

Variables

CmpOptions are the options needed to compare plan.ProcedureSpecs inside plan.Spec.

Functions

func CompareLogicalPlanNodes

func CompareLogicalPlanNodes(p, q plan.Node) error

CompareLogicalPlanNodes is a comparator function for LogicalPlanNodes

func CompareLogicalPlans added in v0.26.0

func CompareLogicalPlans(p, q *plan.Spec) error

CompareLogicalPlans compares two logical plans.

func ComparePhysicalPlanNodes

func ComparePhysicalPlanNodes(p, q plan.Node) error

ComparePhysicalPlanNodes is a comparator function for PhysicalPlanNodes

func ComparePlans

func ComparePlans(p, q *plan.Spec, f func(p, q plan.Node) error) error

ComparePlans compares two query plans using an arbitrary comparator function f

func ComparePlansShallow added in v0.26.0

func ComparePlansShallow(p, q *plan.Spec) error

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 added in v0.158.0

func CreatePhysicalNode(id plan.NodeID, spec plan.PhysicalProcedureSpec) *plan.PhysicalPlanNode

func CreatePlanSpec

func CreatePlanSpec(ps *PlanSpec) *plan.Spec

func LogicalRuleTestHelper added in v0.19.0

func LogicalRuleTestHelper(t *testing.T, tc *RuleTestCase, options ...cmp.Option)

LogicalRuleTestHelper will run a rule test case.

func PhysicalRuleTestHelper added in v0.19.0

func PhysicalRuleTestHelper(t *testing.T, tc *RuleTestCase, options ...cmp.Option)

PhysicalRuleTestHelper will run a rule test case.

Types

type CreateCycleRule added in v0.10.0

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 added in v0.10.0

func (CreateCycleRule) Name() string

func (CreateCycleRule) Pattern added in v0.10.0

func (ccr CreateCycleRule) Pattern() plan.Pattern

func (CreateCycleRule) Rewrite added in v0.10.0

func (ccr CreateCycleRule) Rewrite(ctx context.Context, node plan.Node) (plan.Node, bool, error)

type FunctionRule added in v0.67.0

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 added in v0.67.0

func (fr *FunctionRule) Name() string

func (*FunctionRule) Pattern added in v0.67.0

func (fr *FunctionRule) Pattern() plan.Pattern

func (*FunctionRule) Rewrite added in v0.67.0

func (fr *FunctionRule) Rewrite(ctx context.Context, node plan.Node) (plan.Node, bool, error)

type MockProcedureSpec

type MockProcedureSpec = spec.MockProcedureSpec

type MultiRootRule added in v0.67.0

type MultiRootRule struct {
	SeenNodes []plan.NodeID
}

MultiRootRule matches a set of plan nodes at the root and stores the NodeIDs of nodes it has visited in SeenNodes.

func (*MultiRootRule) Name added in v0.67.0

func (sr *MultiRootRule) Name() string

func (*MultiRootRule) Pattern added in v0.67.0

func (sr *MultiRootRule) Pattern() plan.Pattern

func (*MultiRootRule) Rewrite added in v0.67.0

func (sr *MultiRootRule) Rewrite(ctx context.Context, node plan.Node) (plan.Node, bool, error)

type PlanSpec

type PlanSpec = spec.PlanSpec

type RuleTestCase added in v0.8.0

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

type SimpleRule struct {
	ReturnNilNode bool
	ReturnChanged bool
	SeenNodes     []plan.NodeID
}

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

func (*SimpleRule) Rewrite

func (sr *SimpleRule) Rewrite(ctx context.Context, node plan.Node) (plan.Node, bool, error)

type SmashPlanRule added in v0.10.0

type SmashPlanRule struct {
	Node     plan.Node
	Intruder plan.Node
	Kind     plan.ProcedureKind
}

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 added in v0.10.0

func (SmashPlanRule) Name() string

func (SmashPlanRule) Pattern added in v0.10.0

func (spp SmashPlanRule) Pattern() plan.Pattern

func (SmashPlanRule) Rewrite added in v0.10.0

func (spp SmashPlanRule) Rewrite(ctx context.Context, node plan.Node) (plan.Node, bool, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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