qlbridge: github.com/araddon/qlbridge/plan Index | Files

package plan

import "github.com/araddon/qlbridge/plan"

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

Package Files

context.go plan.go plan.pb.go planner.go planner_mutate.go planner_select.go projection.go sql_rewrite.go

Variables

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")
)
var (
    ErrInvalidLengthPlan = fmt.Errorf("proto: negative length found during unmarshaling")
    ErrIntOverflowPlan   = fmt.Errorf("proto: integer overflow")
)

func RewriteDescribeAsSelect Uses

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

func RewriteShowAsSelect Uses

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

type Alter Uses

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

Alter plan for ALTER {TABLE|COLUMN}

func NewAlter Uses

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

NewAlter create Alter plan task.

func (*Alter) Walk Uses

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

type Command Uses

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

Command for sql commands like SET.

func (*Command) Walk Uses

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

type Context Uses

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 Uses

func NewContext(query string) *Context

NewContext plan context

func NewContextFromPb Uses

func NewContextFromPb(pb *ContextPb) *Context

func (*Context) Equal Uses

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

func (*Context) Recover Uses

func (m *Context) Recover()

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

func (*Context) ToPB Uses

func (m *Context) ToPB() *ContextPb

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

type ContextPb Uses

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 Uses

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

func (*ContextPb) Marshal Uses

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

func (*ContextPb) MarshalTo Uses

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

func (*ContextPb) ProtoMessage Uses

func (*ContextPb) ProtoMessage()

func (*ContextPb) Reset Uses

func (m *ContextPb) Reset()

func (*ContextPb) Size Uses

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

func (*ContextPb) String Uses

func (m *ContextPb) String() string

func (*ContextPb) Unmarshal Uses

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

type Create Uses

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

Create plan for CREATE {SCHEMA|SOURCE|DATABASE}

func NewCreate Uses

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

NewCreate creates a new Create Task plan.

func (*Create) Walk Uses

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

type Delete Uses

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

Delete plan for sql DELETE where

func (*Delete) Walk Uses

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

type Drop Uses

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

Drop plan for DROP {SCHEMA|SOURCE|DATABASE}

func NewDrop Uses

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

NewDrop create Drop plan task.

func (*Drop) Walk Uses

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

type GroupBy Uses

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

GroupBy clause plan

func GroupByFromPB Uses

func GroupByFromPB(pb *PlanPb) *GroupBy

func NewGroupBy Uses

func NewGroupBy(stmt *rel.SqlSelect) *GroupBy

NewGroupBy from SqlSelect statement.

func (*GroupBy) Equal Uses

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

func (*GroupBy) ToPb Uses

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

type GroupByPb Uses

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 Uses

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

func (*GroupByPb) Marshal Uses

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

func (*GroupByPb) MarshalTo Uses

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

func (*GroupByPb) ProtoMessage Uses

func (*GroupByPb) ProtoMessage()

func (*GroupByPb) Reset Uses

func (m *GroupByPb) Reset()

func (*GroupByPb) Size Uses

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

func (*GroupByPb) String Uses

func (m *GroupByPb) String() string

func (*GroupByPb) Unmarshal Uses

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

type Having Uses

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

Having post-aggregation filter plan.

func HavingFromPB Uses

func HavingFromPB(pb *PlanPb) *Having

func NewHaving Uses

func NewHaving(stmt *rel.SqlSelect) *Having

NewHaving from SqlSelect statement.

func (*Having) Equal Uses

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

func (*Having) ToPb Uses

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

type HavingPb Uses

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

func (*HavingPb) Descriptor Uses

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

func (*HavingPb) Marshal Uses

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

func (*HavingPb) MarshalTo Uses

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

func (*HavingPb) ProtoMessage Uses

func (*HavingPb) ProtoMessage()

func (*HavingPb) Reset Uses

func (m *HavingPb) Reset()

func (*HavingPb) Size Uses

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

func (*HavingPb) String Uses

func (m *HavingPb) String() string

func (*HavingPb) Unmarshal Uses

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

type Insert Uses

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

Insert plan

func (*Insert) Walk Uses

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

type Into Uses

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

Into Select INTO table

func (*Into) Equal Uses

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

Equal compares equality of two tasks.

type JoinKey Uses

type JoinKey struct {
    *PlanBase
    Source *Source
}

JoinKey plan

func NewJoinKey Uses

func NewJoinKey(s *Source) *JoinKey

NewJoinKey creates JoinKey from Source.

func (*JoinKey) Equal Uses

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

type JoinKeyPb Uses

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

func (*JoinKeyPb) Descriptor Uses

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

func (*JoinKeyPb) Marshal Uses

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

func (*JoinKeyPb) MarshalTo Uses

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

func (*JoinKeyPb) ProtoMessage Uses

func (*JoinKeyPb) ProtoMessage()

func (*JoinKeyPb) Reset Uses

func (m *JoinKeyPb) Reset()

func (*JoinKeyPb) Size Uses

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

func (*JoinKeyPb) String Uses

func (m *JoinKeyPb) String() string

func (*JoinKeyPb) Unmarshal Uses

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

type JoinMerge Uses

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 Uses

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 Uses

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

type JoinMergePb Uses

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

func (*JoinMergePb) Descriptor Uses

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

func (*JoinMergePb) Marshal Uses

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

func (*JoinMergePb) MarshalTo Uses

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

func (*JoinMergePb) ProtoMessage Uses

func (*JoinMergePb) ProtoMessage()

func (*JoinMergePb) Reset Uses

func (m *JoinMergePb) Reset()

func (*JoinMergePb) Size Uses

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

func (*JoinMergePb) String Uses

func (m *JoinMergePb) String() string

func (*JoinMergePb) Unmarshal Uses

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

type NextIdFunc Uses

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 Uses

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

Order By clause

func NewOrder Uses

func NewOrder(stmt *rel.SqlSelect) *Order

NewOrder from SqlSelect statement.

func OrderFromPB Uses

func OrderFromPB(pb *PlanPb) *Order

func (*Order) Equal Uses

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

func (*Order) ToPb Uses

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

type OrderPb Uses

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

func (*OrderPb) Descriptor Uses

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

func (*OrderPb) Marshal Uses

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

func (*OrderPb) MarshalTo Uses

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

func (*OrderPb) ProtoMessage Uses

func (*OrderPb) ProtoMessage()

func (*OrderPb) Reset Uses

func (m *OrderPb) Reset()

func (*OrderPb) Size Uses

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

func (*OrderPb) String Uses

func (m *OrderPb) String() string

func (*OrderPb) Unmarshal Uses

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

type PlanBase Uses

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

PlanBase holds dag of child tasks

func NewPlanBase Uses

func NewPlanBase(isParallel bool) *PlanBase

func (*PlanBase) Add Uses

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

func (*PlanBase) Children Uses

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

func (*PlanBase) Close Uses

func (m *PlanBase) Close() error

func (*PlanBase) Equal Uses

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

func (*PlanBase) EqualBase Uses

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

func (*PlanBase) IsParallel Uses

func (m *PlanBase) IsParallel() bool

func (*PlanBase) IsSequential Uses

func (m *PlanBase) IsSequential() bool

func (*PlanBase) Run Uses

func (m *PlanBase) Run() error

func (*PlanBase) SetParallel Uses

func (m *PlanBase) SetParallel()

func (*PlanBase) SetSequential Uses

func (m *PlanBase) SetSequential()

func (*PlanBase) ToPb Uses

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

func (*PlanBase) Walk Uses

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

type PlanPb Uses

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 Uses

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

func (*PlanPb) Marshal Uses

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

func (*PlanPb) MarshalTo Uses

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

func (*PlanPb) ProtoMessage Uses

func (*PlanPb) ProtoMessage()

func (*PlanPb) Reset Uses

func (m *PlanPb) Reset()

func (*PlanPb) Size Uses

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

func (*PlanPb) String Uses

func (m *PlanPb) String() string

func (*PlanPb) Unmarshal Uses

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

type Planner Uses

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 Uses

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 Uses

func NewPlanner(ctx *Context) *PlannerDefault

NewPlanner creates a new default planner with context.

func (*PlannerDefault) WalkAlter Uses

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

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

func (*PlannerDefault) WalkCommand Uses

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

WalkCommand walks the command statement

func (*PlannerDefault) WalkCreate Uses

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

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

func (*PlannerDefault) WalkDelete Uses

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

func (*PlannerDefault) WalkDrop Uses

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

WalkDrop walks the draop statement

func (*PlannerDefault) WalkInsert Uses

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

func (*PlannerDefault) WalkInto Uses

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

func (*PlannerDefault) WalkLiteralQuery Uses

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

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

func (*PlannerDefault) WalkPreparedStatement Uses

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

WalkPreparedStatement not implemented

func (*PlannerDefault) WalkProjectionFinal Uses

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

WalkProjectionFinal walk the select plan to create final projection.

func (*PlannerDefault) WalkProjectionSource Uses

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

WalkProjectionSource non final projection (ie, per from).

func (*PlannerDefault) WalkSelect Uses

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

WalkSelect walk a select statement filling out plan.

func (*PlannerDefault) WalkSourceSelect Uses

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

WalkSourceSelect is a single source select

func (*PlannerDefault) WalkUpdate Uses

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

func (*PlannerDefault) WalkUpsert Uses

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

type PreparedStatement Uses

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

PreparedStatement plan

func (*PreparedStatement) Walk Uses

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

type Projection Uses

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 Uses

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

Final Projections project final select columns for result-writing

func NewProjectionInProcess Uses

func NewProjectionInProcess(stmt *rel.SqlSelect) *Projection

func NewProjectionStatic Uses

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 Uses

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

ProjectionFromPB create Projection from Protobuf.

func (*Projection) Equal Uses

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

Equal checks if two tasks are equal.

func (*Projection) ToPb Uses

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

ToPb to protobuf.

type Proto Uses

type Proto interface {
    proto.Marshaler
    proto.Unmarshaler
}

Proto interface to ensure implements protobuf marshalling.

type SchemaLoader Uses

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

SchemaLoader func interface for loading schema.

type Select Uses

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

Select plan

func SelectFromPB Uses

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

func SelectPlanFromPbBytes Uses

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

SelectPlanFromPbBytes Create a sql plan from pb.

func (*Select) Equal Uses

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

func (*Select) IsSchemaQuery Uses

func (m *Select) IsSchemaQuery() bool

func (*Select) Marshal Uses

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

func (*Select) MarshalTo Uses

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

func (*Select) NeedsFinalProjection Uses

func (m *Select) NeedsFinalProjection() bool

func (*Select) Size Uses

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

func (*Select) Unmarshal Uses

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

func (*Select) Walk Uses

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

type SelectPb Uses

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 Uses

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

func (*SelectPb) Marshal Uses

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

func (*SelectPb) MarshalTo Uses

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

func (*SelectPb) ProtoMessage Uses

func (*SelectPb) ProtoMessage()

func (*SelectPb) Reset Uses

func (m *SelectPb) Reset()

func (*SelectPb) Size Uses

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

func (*SelectPb) String Uses

func (m *SelectPb) String() string

func (*SelectPb) Unmarshal Uses

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

type SelectTask Uses

type SelectTask interface {
    Equal(Task) bool
}

SelectTask interface to check equality

type Source Uses

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 Uses

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

NewSource create a new plan Task for data source

func NewSourceStaticPlan Uses

func NewSourceStaticPlan(ctx *Context) *Source

func SourceFromPB Uses

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

func (*Source) Context Uses

func (m *Source) Context() *Context

func (*Source) Equal Uses

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

func (*Source) IsSchemaQuery Uses

func (m *Source) IsSchemaQuery() bool

func (*Source) LoadConn Uses

func (m *Source) LoadConn() error

func (*Source) Marshal Uses

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

func (*Source) MarshalTo Uses

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

func (*Source) Size Uses

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

func (*Source) ToPb Uses

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

func (*Source) Unmarshal Uses

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

func (*Source) Walk Uses

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

type SourcePb Uses

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 Uses

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

func (*SourcePb) Marshal Uses

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

func (*SourcePb) MarshalTo Uses

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

func (*SourcePb) ProtoMessage Uses

func (*SourcePb) ProtoMessage()

func (*SourcePb) Reset Uses

func (m *SourcePb) Reset()

func (*SourcePb) Size Uses

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

func (*SourcePb) String Uses

func (m *SourcePb) String() string

func (*SourcePb) Unmarshal Uses

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

type SourcePlanner Uses

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 Uses

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 Uses

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

SelectTaskFromTaskPb create plan task for SqlSelect from pb.

func WalkStmt Uses

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 Uses

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

Update plan for sql Update statements.

func (*Update) Walk Uses

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

type Upsert Uses

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

Upsert task (not official sql) for sql Upsert.

func (*Upsert) Walk Uses

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

type Where Uses

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

Where pre-aggregation filter

func NewWhere Uses

func NewWhere(stmt *rel.SqlSelect) *Where

NewWhere new Where Task from SqlSelect statement.

func NewWhereFinal Uses

func NewWhereFinal(stmt *rel.SqlSelect) *Where

NewWhereFinal from SqlSelect statement.

func WhereFromPB Uses

func WhereFromPB(pb *PlanPb) *Where

func (*Where) Equal Uses

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

func (*Where) ToPb Uses

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

type WherePb Uses

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 Uses

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

func (*WherePb) Marshal Uses

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

func (*WherePb) MarshalTo Uses

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

func (*WherePb) ProtoMessage Uses

func (*WherePb) ProtoMessage()

func (*WherePb) Reset Uses

func (m *WherePb) Reset()

func (*WherePb) Size Uses

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

func (*WherePb) String Uses

func (m *WherePb) String() string

func (*WherePb) Unmarshal Uses

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

Package plan imports 17 packages (graph) and is imported by 42 packages. Updated 2019-10-30. Refresh now. Tools for package owners.