plan

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 17 Imported by: 76

Documentation

Overview

Plan package converts the AST (expr package) into a plan, which is a DAG of tasks that comprise that plan, the planner is pluggable. The plan tasks are converted to executeable plan in exec.

Package plan is a generated protocol buffer package.

It is generated from these files:
	plan.proto

It has these top-level messages:
	PlanPb
	SelectPb
	ContextPb
	SourcePb
	WherePb
	GroupByPb
	HavingPb
	OrderPb
	JoinMergePb
	JoinKeyPb

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotImplemented is plan specific error for not implemented
	ErrNotImplemented = fmt.Errorf("QLBridge.plan: not implemented")
	// ErrNoDataSource no datasource/type found
	ErrNoDataSource = fmt.Errorf("QLBridge.plan: No datasource found")
	// ErrNoPlan no plan
	ErrNoPlan = fmt.Errorf("No Plan")
)
View Source
var (
	ErrInvalidLengthPlan = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowPlan   = fmt.Errorf("proto: integer overflow")
)

Functions

func RewriteDescribeAsSelect

func RewriteDescribeAsSelect(stmt *rel.SqlDescribe, ctx *Context) (*rel.SqlSelect, error)

func RewriteShowAsSelect

func RewriteShowAsSelect(stmt *rel.SqlShow, ctx *Context) (*rel.SqlSelect, error)

RewriteShowAsSelect Rewrite Schema SHOW Statements AS SELECT statements so we only need a Select Planner, not separate planner for show statements

Types

type Alter

type Alter struct {
	*PlanBase
	Ctx  *Context
	Stmt *rel.SqlAlter
}

Alter plan for ALTER {TABLE|COLUMN}

func NewAlter

func NewAlter(ctx *Context, stmt *rel.SqlAlter) *Alter

NewAlter create Alter plan task.

func (*Alter) Walk

func (m *Alter) Walk(p Planner) error

type Command

type Command struct {
	*PlanBase
	Ctx  *Context
	Stmt *rel.SqlCommand
}

Command for sql commands like SET.

func (*Command) Walk

func (m *Command) Walk(p Planner) error

type Context

type Context struct {

	// Stateful Fields that are transported to participate across network/nodes
	context.Context        // go context for cancelation in plan
	SchemaName      string // schema name to load schema with

	Raw        string           // Raw sql statement
	Stmt       rel.SqlStatement // Original Statement
	Projection *Projection      // Projection for this context optional

	// Local in-memory helpers not transported across network
	Session expr.ContextReadWriter // Session for this connection
	Schema  *schema.Schema         // this schema for this connection
	Funcs   expr.FuncResolver      // Local/Dialect specific functions

	// From configuration
	DisableRecover bool

	// Local State
	Errors []error
	// contains filtered or unexported fields
}

Context for plan of a Relational task has info about the query projection, schema, function resolvers necessary to plan this statement. - may be transported across network boundaries to particpate in dag of tasks - holds references to in-mem data structures for schema - holds references to original statement - holds task specific state for errors, ids, etc (net.context) - manages Recover() - to persist/transport state

func NewContext

func NewContext(query string) *Context

NewContext plan context

func NewContextFromPb

func NewContextFromPb(pb *ContextPb) *Context

func (*Context) Equal

func (m *Context) Equal(c *Context) bool

func (*Context) Recover

func (m *Context) Recover()

called by go routines/tasks to ensure any recovery panics are captured

func (*Context) ToPB

func (m *Context) ToPB() *ContextPb

called by go routines/tasks to ensure any recovery panics are captured

type ContextPb

type ContextPb struct {
	Schema           string `protobuf:"bytes,1,req,name=schema" json:"schema"`
	Id               uint64 `protobuf:"varint,2,req,name=id" json:"id"`
	Fingerprint      uint64 `protobuf:"varint,3,req,name=fingerprint" json:"fingerprint"`
	XXX_unrecognized []byte `json:"-"`
}

Context

func (*ContextPb) Descriptor

func (*ContextPb) Descriptor() ([]byte, []int)

func (*ContextPb) Marshal

func (m *ContextPb) Marshal() (data []byte, err error)

func (*ContextPb) MarshalTo

func (m *ContextPb) MarshalTo(data []byte) (int, error)

func (*ContextPb) ProtoMessage

func (*ContextPb) ProtoMessage()

func (*ContextPb) Reset

func (m *ContextPb) Reset()

func (*ContextPb) Size

func (m *ContextPb) Size() (n int)

func (*ContextPb) String

func (m *ContextPb) String() string

func (*ContextPb) Unmarshal

func (m *ContextPb) Unmarshal(data []byte) error

type Create

type Create struct {
	*PlanBase
	Ctx  *Context
	Stmt *rel.SqlCreate
}

Create plan for CREATE {SCHEMA|SOURCE|DATABASE}

func NewCreate

func NewCreate(ctx *Context, stmt *rel.SqlCreate) *Create

NewCreate creates a new Create Task plan.

func (*Create) Walk

func (m *Create) Walk(p Planner) error

type Delete

type Delete struct {
	*PlanBase
	Stmt   *rel.SqlDelete
	Source schema.ConnDeletion
}

Delete plan for sql DELETE where

func (*Delete) Walk

func (m *Delete) Walk(p Planner) error

type Drop

type Drop struct {
	*PlanBase
	Ctx  *Context
	Stmt *rel.SqlDrop
}

Drop plan for DROP {SCHEMA|SOURCE|DATABASE}

func NewDrop

func NewDrop(ctx *Context, stmt *rel.SqlDrop) *Drop

NewDrop create Drop plan task.

func (*Drop) Walk

func (m *Drop) Walk(p Planner) error

type GroupBy

type GroupBy struct {
	*PlanBase
	Stmt    *rel.SqlSelect
	Partial bool
}

GroupBy clause plan

func GroupByFromPB

func GroupByFromPB(pb *PlanPb) *GroupBy

func NewGroupBy

func NewGroupBy(stmt *rel.SqlSelect) *GroupBy

NewGroupBy from SqlSelect statement.

func (*GroupBy) Equal

func (m *GroupBy) Equal(t Task) bool

func (*GroupBy) ToPb

func (m *GroupBy) ToPb() (*PlanPb, error)

type GroupByPb

type GroupByPb struct {
	Select           *rel.SqlSelectPb `protobuf:"bytes,1,opt,name=select" json:"select,omitempty"`
	XXX_unrecognized []byte           `json:"-"`
}

Group By Plan

func (*GroupByPb) Descriptor

func (*GroupByPb) Descriptor() ([]byte, []int)

func (*GroupByPb) Marshal

func (m *GroupByPb) Marshal() (data []byte, err error)

func (*GroupByPb) MarshalTo

func (m *GroupByPb) MarshalTo(data []byte) (int, error)

func (*GroupByPb) ProtoMessage

func (*GroupByPb) ProtoMessage()

func (*GroupByPb) Reset

func (m *GroupByPb) Reset()

func (*GroupByPb) Size

func (m *GroupByPb) Size() (n int)

func (*GroupByPb) String

func (m *GroupByPb) String() string

func (*GroupByPb) Unmarshal

func (m *GroupByPb) Unmarshal(data []byte) error

type Having

type Having struct {
	*PlanBase
	Stmt *rel.SqlSelect
}

Having post-aggregation filter plan.

func HavingFromPB

func HavingFromPB(pb *PlanPb) *Having

func NewHaving

func NewHaving(stmt *rel.SqlSelect) *Having

NewHaving from SqlSelect statement.

func (*Having) Equal

func (m *Having) Equal(t Task) bool

func (*Having) ToPb

func (m *Having) ToPb() (*PlanPb, error)

type HavingPb

type HavingPb struct {
	Select           *rel.SqlSelectPb `protobuf:"bytes,1,opt,name=select" json:"select,omitempty"`
	XXX_unrecognized []byte           `json:"-"`
}

func (*HavingPb) Descriptor

func (*HavingPb) Descriptor() ([]byte, []int)

func (*HavingPb) Marshal

func (m *HavingPb) Marshal() (data []byte, err error)

func (*HavingPb) MarshalTo

func (m *HavingPb) MarshalTo(data []byte) (int, error)

func (*HavingPb) ProtoMessage

func (*HavingPb) ProtoMessage()

func (*HavingPb) Reset

func (m *HavingPb) Reset()

func (*HavingPb) Size

func (m *HavingPb) Size() (n int)

func (*HavingPb) String

func (m *HavingPb) String() string

func (*HavingPb) Unmarshal

func (m *HavingPb) Unmarshal(data []byte) error

type Insert

type Insert struct {
	*PlanBase
	Stmt   *rel.SqlInsert
	Source schema.ConnUpsert
}

Insert plan

func (*Insert) Walk

func (m *Insert) Walk(p Planner) error

type Into

type Into struct {
	*PlanBase
	Stmt *rel.SqlInto
}

Into Select INTO table

func (*Into) Equal

func (m *Into) Equal(t Task) bool

Equal compares equality of two tasks.

type JoinKey

type JoinKey struct {
	*PlanBase
	Source *Source
}

JoinKey plan

func NewJoinKey

func NewJoinKey(s *Source) *JoinKey

NewJoinKey creates JoinKey from Source.

func (*JoinKey) Equal

func (m *JoinKey) Equal(t Task) bool

type JoinKeyPb

type JoinKeyPb struct {
	Having           *expr.NodePb `protobuf:"bytes,1,opt,name=having" json:"having,omitempty"`
	XXX_unrecognized []byte       `json:"-"`
}

func (*JoinKeyPb) Descriptor

func (*JoinKeyPb) Descriptor() ([]byte, []int)

func (*JoinKeyPb) Marshal

func (m *JoinKeyPb) Marshal() (data []byte, err error)

func (*JoinKeyPb) MarshalTo

func (m *JoinKeyPb) MarshalTo(data []byte) (int, error)

func (*JoinKeyPb) ProtoMessage

func (*JoinKeyPb) ProtoMessage()

func (*JoinKeyPb) Reset

func (m *JoinKeyPb) Reset()

func (*JoinKeyPb) Size

func (m *JoinKeyPb) Size() (n int)

func (*JoinKeyPb) String

func (m *JoinKeyPb) String() string

func (*JoinKeyPb) Unmarshal

func (m *JoinKeyPb) Unmarshal(data []byte) error

type JoinMerge

type JoinMerge struct {
	*PlanBase
	Left      Task
	Right     Task
	LeftFrom  *rel.SqlSource
	RightFrom *rel.SqlSource
	ColIndex  map[string]int
}

JoinMerge 2 source/input tasks for join

func NewJoinMerge

func NewJoinMerge(l, r Task, lf, rf *rel.SqlSource) *JoinMerge

NewJoinMerge A parallel join merge, uses Key() as value to merge two different input task/channels.

left source  ->
               \
                 --  join  -->
               /
right source ->

func (*JoinMerge) Equal

func (m *JoinMerge) Equal(t Task) bool

type JoinMergePb

type JoinMergePb struct {
	Having           *expr.NodePb `protobuf:"bytes,1,opt,name=having" json:"having,omitempty"`
	XXX_unrecognized []byte       `json:"-"`
}

func (*JoinMergePb) Descriptor

func (*JoinMergePb) Descriptor() ([]byte, []int)

func (*JoinMergePb) Marshal

func (m *JoinMergePb) Marshal() (data []byte, err error)

func (*JoinMergePb) MarshalTo

func (m *JoinMergePb) MarshalTo(data []byte) (int, error)

func (*JoinMergePb) ProtoMessage

func (*JoinMergePb) ProtoMessage()

func (*JoinMergePb) Reset

func (m *JoinMergePb) Reset()

func (*JoinMergePb) Size

func (m *JoinMergePb) Size() (n int)

func (*JoinMergePb) String

func (m *JoinMergePb) String() string

func (*JoinMergePb) Unmarshal

func (m *JoinMergePb) Unmarshal(data []byte) error

type NextIdFunc

type NextIdFunc func() uint64

NextIdFunc is the id generation function to give statements their own id

var NextId NextIdFunc

NextId is the global next id generation function

type Order

type Order struct {
	*PlanBase
	Stmt *rel.SqlSelect
}

Order By clause

func NewOrder

func NewOrder(stmt *rel.SqlSelect) *Order

NewOrder from SqlSelect statement.

func OrderFromPB

func OrderFromPB(pb *PlanPb) *Order

func (*Order) Equal

func (m *Order) Equal(t Task) bool

func (*Order) ToPb

func (m *Order) ToPb() (*PlanPb, error)

type OrderPb

type OrderPb struct {
	Select           *rel.SqlSelectPb `protobuf:"bytes,1,opt,name=select" json:"select,omitempty"`
	XXX_unrecognized []byte           `json:"-"`
}

func (*OrderPb) Descriptor

func (*OrderPb) Descriptor() ([]byte, []int)

func (*OrderPb) Marshal

func (m *OrderPb) Marshal() (data []byte, err error)

func (*OrderPb) MarshalTo

func (m *OrderPb) MarshalTo(data []byte) (int, error)

func (*OrderPb) ProtoMessage

func (*OrderPb) ProtoMessage()

func (*OrderPb) Reset

func (m *OrderPb) Reset()

func (*OrderPb) Size

func (m *OrderPb) Size() (n int)

func (*OrderPb) String

func (m *OrderPb) String() string

func (*OrderPb) Unmarshal

func (m *OrderPb) Unmarshal(data []byte) error

type PlanBase

type PlanBase struct {
	RootTask Task // Root task
	// contains filtered or unexported fields
}

PlanBase holds dag of child tasks

func NewPlanBase

func NewPlanBase(isParallel bool) *PlanBase

func (*PlanBase) Add

func (m *PlanBase) Add(task Task) error

func (*PlanBase) Children

func (m *PlanBase) Children() []Task

func (*PlanBase) Close

func (m *PlanBase) Close() error

func (*PlanBase) Equal

func (m *PlanBase) Equal(t Task) bool

func (*PlanBase) EqualBase

func (m *PlanBase) EqualBase(p *PlanBase) bool

func (*PlanBase) IsParallel

func (m *PlanBase) IsParallel() bool

func (*PlanBase) IsSequential

func (m *PlanBase) IsSequential() bool

func (*PlanBase) Run

func (m *PlanBase) Run() error

func (*PlanBase) SetParallel

func (m *PlanBase) SetParallel()

func (*PlanBase) SetSequential

func (m *PlanBase) SetSequential()

func (*PlanBase) ToPb

func (m *PlanBase) ToPb() (*PlanPb, error)

func (*PlanBase) Walk

func (m *PlanBase) Walk(p Planner) error

type PlanPb

type PlanPb struct {
	Parallel         bool              `protobuf:"varint,1,req,name=parallel" json:"parallel"`
	Select           *SelectPb         `protobuf:"bytes,3,opt,name=select" json:"select,omitempty"`
	Source           *SourcePb         `protobuf:"bytes,4,opt,name=source" json:"source,omitempty"`
	Where            *WherePb          `protobuf:"bytes,5,opt,name=where" json:"where,omitempty"`
	Having           *HavingPb         `protobuf:"bytes,6,opt,name=having" json:"having,omitempty"`
	GroupBy          *GroupByPb        `protobuf:"bytes,7,opt,name=groupBy" json:"groupBy,omitempty"`
	Order            *OrderPb          `protobuf:"bytes,8,opt,name=order" json:"order,omitempty"`
	JoinMerge        *JoinMergePb      `protobuf:"bytes,9,opt,name=joinMerge" json:"joinMerge,omitempty"`
	JoinKey          *JoinKeyPb        `protobuf:"bytes,10,opt,name=joinKey" json:"joinKey,omitempty"`
	Projection       *rel.ProjectionPb `protobuf:"bytes,11,opt,name=projection" json:"projection,omitempty"`
	Children         []*PlanPb         `protobuf:"bytes,12,rep,name=children" json:"children,omitempty"`
	XXX_unrecognized []byte            `json:"-"`
}

The generic Node, must be exactly one of these types

func (*PlanPb) Descriptor

func (*PlanPb) Descriptor() ([]byte, []int)

func (*PlanPb) Marshal

func (m *PlanPb) Marshal() (data []byte, err error)

func (*PlanPb) MarshalTo

func (m *PlanPb) MarshalTo(data []byte) (int, error)

func (*PlanPb) ProtoMessage

func (*PlanPb) ProtoMessage()

func (*PlanPb) Reset

func (m *PlanPb) Reset()

func (*PlanPb) Size

func (m *PlanPb) Size() (n int)

func (*PlanPb) String

func (m *PlanPb) String() string

func (*PlanPb) Unmarshal

func (m *PlanPb) Unmarshal(data []byte) error

type Planner

type Planner interface {
	// DML Statements
	WalkSelect(p *Select) error
	WalkInsert(p *Insert) error
	WalkUpsert(p *Upsert) error
	WalkUpdate(p *Update) error
	WalkDelete(p *Delete) error
	WalkInto(p *Into) error
	WalkSourceSelect(p *Source) error
	WalkProjectionSource(p *Source) error
	WalkProjectionFinal(p *Select) error

	// Other Statements
	WalkPreparedStatement(p *PreparedStatement) error
	WalkCommand(p *Command) error

	// DDL operations
	WalkCreate(p *Create) error
	WalkDrop(p *Drop) error
	WalkAlter(p *Alter) error
}

Planner interface for planners. Planners take a statement and walk the statement to create a DAG of tasks representing necessary sub-tasks to fulfil statement. implementations of planners: - qlbridge/exec package implements a non-distributed query-planner - dataux/planner implements a distributed query-planner

type PlannerDefault

type PlannerDefault struct {
	Planner Planner
	Ctx     *Context
	// contains filtered or unexported fields
}

PlannerDefault is implementation of Planner that creates a dag of plan.Tasks that will be turned into execution plan by executor. This is a simple planner but can be over-ridden by providing a Planner that will supercede any single or more visit methods. - stateful, specific to a single request

func NewPlanner

func NewPlanner(ctx *Context) *PlannerDefault

NewPlanner creates a new default planner with context.

func (*PlannerDefault) WalkAlter

func (m *PlannerDefault) WalkAlter(p *Alter) error

WalkAlter walk a ALTER Plan to create the dag of tasks forAlter.

func (*PlannerDefault) WalkCommand

func (m *PlannerDefault) WalkCommand(p *Command) error

WalkCommand walks the command statement

func (*PlannerDefault) WalkCreate

func (m *PlannerDefault) WalkCreate(p *Create) error

WalkCreate walk a Create Plan to create the dag of tasks for Create.

func (*PlannerDefault) WalkDelete

func (m *PlannerDefault) WalkDelete(p *Delete) error

func (*PlannerDefault) WalkDrop

func (m *PlannerDefault) WalkDrop(p *Drop) error

WalkDrop walks the draop statement

func (*PlannerDefault) WalkInsert

func (m *PlannerDefault) WalkInsert(p *Insert) error

func (*PlannerDefault) WalkInto

func (m *PlannerDefault) WalkInto(p *Into) error

func (*PlannerDefault) WalkLiteralQuery

func (m *PlannerDefault) WalkLiteralQuery(p *Select) error

WalkLiteralQuery Handle Literal queries such as "SELECT 1, @var;"

func (*PlannerDefault) WalkPreparedStatement

func (m *PlannerDefault) WalkPreparedStatement(p *PreparedStatement) error

WalkPreparedStatement not implemented

func (*PlannerDefault) WalkProjectionFinal

func (m *PlannerDefault) WalkProjectionFinal(p *Select) error

WalkProjectionFinal walk the select plan to create final projection.

func (*PlannerDefault) WalkProjectionSource

func (m *PlannerDefault) WalkProjectionSource(p *Source) error

WalkProjectionSource non final projection (ie, per from).

func (*PlannerDefault) WalkSelect

func (m *PlannerDefault) WalkSelect(p *Select) error

WalkSelect walk a select statement filling out plan.

func (*PlannerDefault) WalkSourceSelect

func (m *PlannerDefault) WalkSourceSelect(p *Source) error

WalkSourceSelect is a single source select

func (*PlannerDefault) WalkUpdate

func (m *PlannerDefault) WalkUpdate(p *Update) error

func (*PlannerDefault) WalkUpsert

func (m *PlannerDefault) WalkUpsert(p *Upsert) error

type PreparedStatement

type PreparedStatement struct {
	*PlanBase
	Stmt *rel.PreparedStatement
}

PreparedStatement plan

func (*PreparedStatement) Walk

func (m *PreparedStatement) Walk(p Planner) error

type Projection

type Projection struct {
	*PlanBase
	Final bool // Is this final projection or not?
	P     *Select
	Stmt  *rel.SqlSelect
	Proj  *rel.Projection
}

Projection holds original query for column info and schema/field types

func NewProjectionFinal

func NewProjectionFinal(ctx *Context, p *Select) (*Projection, error)

Final Projections project final select columns for result-writing

func NewProjectionInProcess

func NewProjectionInProcess(stmt *rel.SqlSelect) *Projection

func NewProjectionStatic

func NewProjectionStatic(proj *rel.Projection) *Projection

A static projection has already had its column/types defined

and doesn't need to use internal schema to find it, often internal SHOW/DESCRIBE

func ProjectionFromPB

func ProjectionFromPB(pb *PlanPb, sel *rel.SqlSelect) *Projection

ProjectionFromPB create Projection from Protobuf.

func (*Projection) Equal

func (m *Projection) Equal(t Task) bool

Equal checks if two tasks are equal.

func (*Projection) ToPb

func (m *Projection) ToPb() (*PlanPb, error)

ToPb to protobuf.

type Proto

type Proto interface {
	proto.Marshaler
	proto.Unmarshaler
}

Proto interface to ensure implements protobuf marshalling.

type SchemaLoader

type SchemaLoader func(name string) (*schema.Schema, error)

SchemaLoader func interface for loading schema.

type Select

type Select struct {
	*PlanBase
	Ctx      *Context
	From     []*Source
	Stmt     *rel.SqlSelect
	ChildDag bool
	// contains filtered or unexported fields
}

Select plan

func SelectFromPB

func SelectFromPB(pb *PlanPb, loader SchemaLoader) (*Select, error)

func SelectPlanFromPbBytes

func SelectPlanFromPbBytes(pb []byte, loader SchemaLoader) (*Select, error)

SelectPlanFromPbBytes Create a sql plan from pb.

func (*Select) Equal

func (m *Select) Equal(t Task) bool

func (*Select) IsSchemaQuery

func (m *Select) IsSchemaQuery() bool

func (*Select) Marshal

func (m *Select) Marshal() ([]byte, error)

func (*Select) MarshalTo

func (m *Select) MarshalTo(data []byte) (int, error)

func (*Select) NeedsFinalProjection

func (m *Select) NeedsFinalProjection() bool

func (*Select) Size

func (m *Select) Size() (n int)

func (*Select) Unmarshal

func (m *Select) Unmarshal(data []byte) error

func (*Select) Walk

func (m *Select) Walk(p Planner) error

type SelectPb

type SelectPb struct {
	Select           *rel.SqlSelectPb `protobuf:"bytes,1,req,name=select" json:"select,omitempty"`
	Context          *ContextPb       `protobuf:"bytes,2,opt,name=context" json:"context,omitempty"`
	XXX_unrecognized []byte           `json:"-"`
}

Select Plan

func (*SelectPb) Descriptor

func (*SelectPb) Descriptor() ([]byte, []int)

func (*SelectPb) Marshal

func (m *SelectPb) Marshal() (data []byte, err error)

func (*SelectPb) MarshalTo

func (m *SelectPb) MarshalTo(data []byte) (int, error)

func (*SelectPb) ProtoMessage

func (*SelectPb) ProtoMessage()

func (*SelectPb) Reset

func (m *SelectPb) Reset()

func (*SelectPb) Size

func (m *SelectPb) Size() (n int)

func (*SelectPb) String

func (m *SelectPb) String() string

func (*SelectPb) Unmarshal

func (m *SelectPb) Unmarshal(data []byte) error

type SelectTask

type SelectTask interface {
	Equal(Task) bool
}

SelectTask interface to check equality

type Source

type Source struct {
	*PlanBase

	// Request Information, if cross-node distributed query must be serialized
	*SourcePb
	Stmt     *rel.SqlSource  // The sub-query statement (may have been rewritten)
	Proj     *rel.Projection // projection for this sub-query
	ExecPlan Proto           // If SourceExec has a plan?
	Custom   u.JsonHelper    // Source specific context info

	DataSource schema.Source  // The data source for this From
	Conn       schema.Conn    // Connection for this source, only for this source/task
	Schema     *schema.Schema // Schema for this source/from
	Tbl        *schema.Table  // Table schema for this From
	Static     []driver.Value // this is static data source
	Cols       []string
	// contains filtered or unexported fields
}

Source defines a source Within a Select query, it optionally has multiple sources such as sub-select, join, etc this is the plan for a each source

func NewSource

func NewSource(ctx *Context, stmt *rel.SqlSource, isFinal bool) (*Source, error)

NewSource create a new plan Task for data source

func NewSourceStaticPlan

func NewSourceStaticPlan(ctx *Context) *Source

func SourceFromPB

func SourceFromPB(pb *PlanPb, ctx *Context) (*Source, error)

func (*Source) Context

func (m *Source) Context() *Context

func (*Source) Equal

func (m *Source) Equal(t Task) bool

func (*Source) IsSchemaQuery

func (m *Source) IsSchemaQuery() bool

func (*Source) LoadConn

func (m *Source) LoadConn() error

func (*Source) Marshal

func (m *Source) Marshal() ([]byte, error)

func (*Source) MarshalTo

func (m *Source) MarshalTo(data []byte) (n int, err error)

func (*Source) Size

func (m *Source) Size() (n int)

func (*Source) ToPb

func (m *Source) ToPb() (*PlanPb, error)

func (*Source) Unmarshal

func (m *Source) Unmarshal(data []byte) error

func (*Source) Walk

func (m *Source) Walk(p Planner) error

type SourcePb

type SourcePb struct {
	// do we need group-by, join, partition key for routing purposes?
	NeedsHashableKey bool `protobuf:"varint,2,req,name=needsHashableKey" json:"needsHashableKey"`
	// Is this final projection or not?  non finals are partial-sub-query types
	Final bool `protobuf:"varint,3,req,name=final" json:"final"`
	// Is this plan complete as is?  skip remaining plan walk steps
	Complete         bool              `protobuf:"varint,4,req,name=complete" json:"complete"`
	Join             bool              `protobuf:"varint,5,req,name=join" json:"join"`
	SourceExec       bool              `protobuf:"varint,6,req,name=sourceExec" json:"sourceExec"`
	Custom           []byte            `protobuf:"bytes,7,opt,name=custom" json:"custom,omitempty"`
	SqlSource        *rel.SqlSourcePb  `protobuf:"bytes,8,opt,name=sqlSource" json:"sqlSource,omitempty"`
	Projection       *rel.ProjectionPb `protobuf:"bytes,9,opt,name=projection" json:"projection,omitempty"`
	XXX_unrecognized []byte            `json:"-"`
}

Source Plan is a plan for single source of select query, of which many may exist (joins, sub-querys etc)

func (*SourcePb) Descriptor

func (*SourcePb) Descriptor() ([]byte, []int)

func (*SourcePb) Marshal

func (m *SourcePb) Marshal() (data []byte, err error)

func (*SourcePb) MarshalTo

func (m *SourcePb) MarshalTo(data []byte) (int, error)

func (*SourcePb) ProtoMessage

func (*SourcePb) ProtoMessage()

func (*SourcePb) Reset

func (m *SourcePb) Reset()

func (*SourcePb) Size

func (m *SourcePb) Size() (n int)

func (*SourcePb) String

func (m *SourcePb) String() string

func (*SourcePb) Unmarshal

func (m *SourcePb) Unmarshal(data []byte) error

type SourcePlanner

type SourcePlanner interface {
	// given our request statement, turn that into a plan.Task.
	WalkSourceSelect(pl Planner, s *Source) (Task, error)
}

SourcePlanner Sources can often do their own planning for sub-select statements ie mysql can do its own (select, projection) mongo, es can as well - provide interface to allow passing down select planning to source

type Task

type Task interface {
	// Walk, give a planner to this task to allow
	// Task to call appropriate parts of planner.
	Walk(p Planner) error

	// Children tasks of this, this task may be participating
	// in parents.
	Children() []Task
	// Add a child to this dag
	Add(Task) error
	IsSequential() bool
	SetSequential()
	IsParallel() bool
	SetParallel()
	Equal(Task) bool
	ToPb() (*PlanPb, error)
}

Task interface allows different portions of distributed plans (where, group-by, source-scan, project) to have its own planner. Output is a DAG of tasks to be given to executor. - may be parallel or sequential - must be serializeable to participate in cross network tasks

func SelectTaskFromTaskPb

func SelectTaskFromTaskPb(pb *PlanPb, ctx *Context, sel *rel.SqlSelect) (Task, error)

SelectTaskFromTaskPb create plan task for SqlSelect from pb.

func WalkStmt

func WalkStmt(ctx *Context, stmt rel.SqlStatement, planner Planner) (Task, error)

WalkStmt Walk given statement for given Planner to produce a query plan which is a plan.Task and children, ie a DAG of tasks

type Update

type Update struct {
	*PlanBase
	Stmt   *rel.SqlUpdate
	Source schema.ConnUpsert
}

Update plan for sql Update statements.

func (*Update) Walk

func (m *Update) Walk(p Planner) error

type Upsert

type Upsert struct {
	*PlanBase
	Stmt   *rel.SqlUpsert
	Source schema.ConnUpsert
}

Upsert task (not official sql) for sql Upsert.

func (*Upsert) Walk

func (m *Upsert) Walk(p Planner) error

type Where

type Where struct {
	*PlanBase
	Final bool
	Stmt  *rel.SqlSelect
}

Where pre-aggregation filter

func NewWhere

func NewWhere(stmt *rel.SqlSelect) *Where

NewWhere new Where Task from SqlSelect statement.

func NewWhereFinal

func NewWhereFinal(stmt *rel.SqlSelect) *Where

NewWhereFinal from SqlSelect statement.

func WhereFromPB

func WhereFromPB(pb *PlanPb) *Where

func (*Where) Equal

func (m *Where) Equal(t Task) bool

func (*Where) ToPb

func (m *Where) ToPb() (*PlanPb, error)

type WherePb

type WherePb struct {
	Select           *rel.SqlSelectPb `protobuf:"bytes,1,opt,name=select" json:"select,omitempty"`
	Final            bool             `protobuf:"varint,2,req,name=final" json:"final"`
	XXX_unrecognized []byte           `json:"-"`
}

Where Plan

func (*WherePb) Descriptor

func (*WherePb) Descriptor() ([]byte, []int)

func (*WherePb) Marshal

func (m *WherePb) Marshal() (data []byte, err error)

func (*WherePb) MarshalTo

func (m *WherePb) MarshalTo(data []byte) (int, error)

func (*WherePb) ProtoMessage

func (*WherePb) ProtoMessage()

func (*WherePb) Reset

func (m *WherePb) Reset()

func (*WherePb) Size

func (m *WherePb) Size() (n int)

func (*WherePb) String

func (m *WherePb) String() string

func (*WherePb) Unmarshal

func (m *WherePb) Unmarshal(data []byte) error

Jump to

Keyboard shortcuts

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