plan

package
v0.0.0-...-e79d762 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotIndexable is returned when the table is not indexable.
	ErrNotIndexable = errors.NewKind("the table is not indexable")

	// ErrInvalidIndexDriver is returned when the index driver can't be found.
	ErrInvalidIndexDriver = errors.NewKind("invalid driver index %q")

	// ErrTableNotNameable is returned when the table name can't be obtained.
	ErrTableNotNameable = errors.NewKind("can't get the name from the table")
)
View Source
var DescribeSchema = sql.Schema{
	{Name: "plan", Type: sql.Text},
}

DescribeSchema is the schema returned by a DescribeQuery node.

View Source
var ErrCreateTable = errors.NewKind("tables cannot be created on database %s")

ErrCreateTable is thrown when the database doesn't support table creation

View Source
var ErrGroupBy = errors.NewKind("group by aggregation '%v' not supported")

ErrGroupBy is returned when the aggregation is not supported.

View Source
var ErrIndexNotFound = errors.NewKind("unable to find index %q on table %q of database %q")

ErrIndexNotFound is returned when the index cannot be found.

View Source
var ErrInsertIntoNotSupported = errors.NewKind("table doesn't support INSERT INTO")

ErrInsertIntoNotSupported is thrown when a table doesn't support inserts

View Source
var ErrUnableSort = errors.NewKind("unable to sort")

ErrUnableSort is thrown when something happens on sorting

View Source
var ErrUnresolvedTable = errors.NewKind("unresolved table")

ErrUnresolvedTable is thrown when a table cannot be resolved

Functions

func Inspect

func Inspect(node sql.Node, f func(sql.Node) bool)

Inspect traverses the plan in depth-first order: It starts by calling f(node); node must not be nil. If f returns true, Inspect invokes f recursively for each of the children of node, followed by a call of f(nil).

func InspectExpressions

func InspectExpressions(node sql.Node, f func(sql.Expression) bool)

InspectExpressions traverses the plan and calls expression.Inspect on any expression it finds.

func Walk

func Walk(v Visitor, node sql.Node)

Walk traverses the plan tree in depth-first order. It starts by calling v.Visit(node); node must not be nil. If the visitor returned by v.Visit(node) is not nil, Walk is invoked recursively with the returned visitor for each children of the node, followed by a call of v.Visit(nil) to the returned visitor.

func WalkExpressions

func WalkExpressions(v expression.Visitor, node sql.Node)

WalkExpressions traverses the plan and calls expression.Walk on any expression it finds.

Types

type BinaryNode

type BinaryNode struct {
	Left  sql.Node
	Right sql.Node
}

BinaryNode is a node with two children.

func (BinaryNode) Children

func (n BinaryNode) Children() []sql.Node

Children implements the Node interface.

func (BinaryNode) Resolved

func (n BinaryNode) Resolved() bool

Resolved implements the Resolvable interface.

type CreateIndex

type CreateIndex struct {
	Name            string
	Table           sql.Node
	Exprs           []sql.Expression
	Driver          string
	Config          map[string]string
	Catalog         *sql.Catalog
	CurrentDatabase string
}

CreateIndex is a node to create an index.

func NewCreateIndex

func NewCreateIndex(
	name string,
	table sql.Node,
	exprs []sql.Expression,
	driver string,
	config map[string]string,
) *CreateIndex

NewCreateIndex creates a new CreateIndex node.

func (*CreateIndex) Children

func (c *CreateIndex) Children() []sql.Node

Children implements the Node interface.

func (*CreateIndex) Expressions

func (c *CreateIndex) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*CreateIndex) Resolved

func (c *CreateIndex) Resolved() bool

Resolved implements the Node interface.

func (*CreateIndex) RowIter

func (c *CreateIndex) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*CreateIndex) Schema

func (c *CreateIndex) Schema() sql.Schema

Schema implements the Node interface.

func (*CreateIndex) String

func (c *CreateIndex) String() string

func (*CreateIndex) TransformExpressions

func (c *CreateIndex) TransformExpressions(fn sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*CreateIndex) TransformExpressionsUp

func (c *CreateIndex) TransformExpressionsUp(fn sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*CreateIndex) TransformUp

func (c *CreateIndex) TransformUp(fn sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Node interface.

type CreateTable

type CreateTable struct {
	Database sql.Database
	// contains filtered or unexported fields
}

CreateTable is a node describing the creation of some table.

func NewCreateTable

func NewCreateTable(db sql.Database, name string, schema sql.Schema) *CreateTable

NewCreateTable creates a new CreateTable node

func (*CreateTable) Children

func (c *CreateTable) Children() []sql.Node

Children implements the Node interface.

func (*CreateTable) Resolved

func (c *CreateTable) Resolved() bool

Resolved implements the Resolvable interface.

func (*CreateTable) RowIter

func (c *CreateTable) RowIter(s *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*CreateTable) Schema

func (c *CreateTable) Schema() sql.Schema

Schema implements the Node interface.

func (*CreateTable) String

func (c *CreateTable) String() string

func (*CreateTable) TransformExpressionsUp

func (c *CreateTable) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*CreateTable) TransformUp

func (c *CreateTable) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type CrossJoin

type CrossJoin struct {
	BinaryNode
}

CrossJoin is a cross join between two tables.

func NewCrossJoin

func NewCrossJoin(left sql.Node, right sql.Node) *CrossJoin

NewCrossJoin creates a new cross join node from two tables.

func (*CrossJoin) Resolved

func (p *CrossJoin) Resolved() bool

Resolved implements the Resolvable interface.

func (*CrossJoin) RowIter

func (p *CrossJoin) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*CrossJoin) Schema

func (p *CrossJoin) Schema() sql.Schema

Schema implements the Node interface.

func (*CrossJoin) String

func (p *CrossJoin) String() string

func (*CrossJoin) TransformExpressionsUp

func (p *CrossJoin) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*CrossJoin) TransformUp

func (p *CrossJoin) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type Describe

type Describe struct {
	UnaryNode
}

Describe is a node that describes its children.

func NewDescribe

func NewDescribe(child sql.Node) *Describe

NewDescribe creates a new Describe node.

func (*Describe) RowIter

func (d *Describe) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*Describe) Schema

func (d *Describe) Schema() sql.Schema

Schema implements the Node interface.

func (Describe) String

func (d Describe) String() string

func (*Describe) TransformExpressionsUp

func (d *Describe) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Describe) TransformUp

func (d *Describe) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type DescribeQuery

type DescribeQuery struct {
	UnaryNode
	Format string
}

DescribeQuery returns the description of the query plan.

func NewDescribeQuery

func NewDescribeQuery(format string, child sql.Node) *DescribeQuery

NewDescribeQuery creates a new DescribeQuery node.

func (*DescribeQuery) RowIter

func (d *DescribeQuery) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*DescribeQuery) Schema

func (d *DescribeQuery) Schema() sql.Schema

Schema implements the Node interface.

func (*DescribeQuery) String

func (d *DescribeQuery) String() string

func (*DescribeQuery) TransformExpressionsUp

func (d *DescribeQuery) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*DescribeQuery) TransformUp

func (d *DescribeQuery) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Node interface.

type Distinct

type Distinct struct {
	UnaryNode
}

Distinct is a node that ensures all rows that come from it are unique.

func NewDistinct

func NewDistinct(child sql.Node) *Distinct

NewDistinct creates a new Distinct node.

func (*Distinct) Resolved

func (d *Distinct) Resolved() bool

Resolved implements the Resolvable interface.

func (*Distinct) RowIter

func (d *Distinct) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (Distinct) String

func (d Distinct) String() string

func (*Distinct) TransformExpressionsUp

func (d *Distinct) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Distinct) TransformUp

func (d *Distinct) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type DropIndex

type DropIndex struct {
	Name            string
	Table           sql.Node
	Catalog         *sql.Catalog
	CurrentDatabase string
}

DropIndex is a node to drop an index.

func NewDropIndex

func NewDropIndex(name string, table sql.Node) *DropIndex

NewDropIndex creates a new DropIndex node.

func (*DropIndex) Children

func (d *DropIndex) Children() []sql.Node

Children implements the Node interface.

func (*DropIndex) Resolved

func (d *DropIndex) Resolved() bool

Resolved implements the Node interface.

func (*DropIndex) RowIter

func (d *DropIndex) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*DropIndex) Schema

func (d *DropIndex) Schema() sql.Schema

Schema implements the Node interface.

func (*DropIndex) String

func (d *DropIndex) String() string

func (*DropIndex) TransformExpressionsUp

func (d *DropIndex) TransformExpressionsUp(fn sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*DropIndex) TransformUp

func (d *DropIndex) TransformUp(fn sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Node interface.

type Filter

type Filter struct {
	UnaryNode
	Expression sql.Expression
}

Filter skips rows that don't match a certain expression.

func NewFilter

func NewFilter(expression sql.Expression, child sql.Node) *Filter

NewFilter creates a new filter node.

func (*Filter) Expressions

func (p *Filter) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*Filter) Resolved

func (p *Filter) Resolved() bool

Resolved implements the Resolvable interface.

func (*Filter) RowIter

func (p *Filter) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*Filter) String

func (p *Filter) String() string

func (*Filter) TransformExpressions

func (p *Filter) TransformExpressions(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*Filter) TransformExpressionsUp

func (p *Filter) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Filter) TransformUp

func (p *Filter) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type FilterIter

type FilterIter struct {
	// contains filtered or unexported fields
}

FilterIter is an iterator that filters another iterator and skips rows that don't match the given condition.

func NewFilterIter

func NewFilterIter(
	ctx *sql.Context,
	cond sql.Expression,
	child sql.RowIter,
) *FilterIter

NewFilterIter creates a new FilterIter.

func (*FilterIter) Close

func (i *FilterIter) Close() error

Close implements the RowIter interface.

func (*FilterIter) Next

func (i *FilterIter) Next() (sql.Row, error)

Next implements the RowIter interface.

type GroupBy

type GroupBy struct {
	UnaryNode
	Aggregate []sql.Expression
	Grouping  []sql.Expression
}

GroupBy groups the rows by some expressions.

func NewGroupBy

func NewGroupBy(
	aggregate []sql.Expression,
	grouping []sql.Expression,
	child sql.Node,
) *GroupBy

NewGroupBy creates a new GroupBy node.

func (*GroupBy) Expressions

func (p *GroupBy) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*GroupBy) Resolved

func (p *GroupBy) Resolved() bool

Resolved implements the Resolvable interface.

func (*GroupBy) RowIter

func (p *GroupBy) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*GroupBy) Schema

func (p *GroupBy) Schema() sql.Schema

Schema implements the Node interface.

func (*GroupBy) String

func (p *GroupBy) String() string

func (*GroupBy) TransformExpressions

func (p *GroupBy) TransformExpressions(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*GroupBy) TransformExpressionsUp

func (p *GroupBy) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*GroupBy) TransformUp

func (p *GroupBy) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type IndexableTable

type IndexableTable struct {
	sql.Indexable
	Columns []sql.Expression
	Filters []sql.Expression
	Index   sql.IndexLookup
}

IndexableTable is a node wrapping a table implementing the sql.Inedxable interface so it returns a RowIter with custom logic given the set of used columns that need to be projected, the filtes that apply to that table and the indexes to use. IndexableTable nodes don't propagate transformations to the underlying table.

func NewIndexableTable

func NewIndexableTable(
	columns []sql.Expression,
	filters []sql.Expression,
	index sql.IndexLookup,
	table sql.Indexable,
) *IndexableTable

NewPushdownProjectionAndFiltersTable creates a new PushdownProjectionAndFiltersTable node.

func (IndexableTable) Children

func (t IndexableTable) Children() []sql.Node

Children implements the Node interface.

func (IndexableTable) Expressions

func (t IndexableTable) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*IndexableTable) RowIter

func (t *IndexableTable) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (IndexableTable) String

func (t IndexableTable) String() string

func (*IndexableTable) TransformExpressionsUp

func (t *IndexableTable) TransformExpressionsUp(
	f sql.TransformExprFunc,
) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*IndexableTable) TransformUp

func (t *IndexableTable) TransformUp(
	f sql.TransformNodeFunc,
) (sql.Node, error)

TransformUp implements the Node interface.

type InnerJoin

type InnerJoin struct {
	BinaryNode
	Cond sql.Expression
}

InnerJoin is an inner join between two tables.

func NewInnerJoin

func NewInnerJoin(left, right sql.Node, cond sql.Expression) *InnerJoin

NewInnerJoin creates a new inner join node from two tables.

func (*InnerJoin) Expressions

func (j *InnerJoin) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*InnerJoin) Resolved

func (j *InnerJoin) Resolved() bool

Resolved implements the Resolvable interface.

func (*InnerJoin) RowIter

func (j *InnerJoin) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*InnerJoin) Schema

func (j *InnerJoin) Schema() sql.Schema

Schema implements the Node interface.

func (*InnerJoin) String

func (j *InnerJoin) String() string

func (*InnerJoin) TransformExpressions

func (j *InnerJoin) TransformExpressions(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*InnerJoin) TransformExpressionsUp

func (j *InnerJoin) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*InnerJoin) TransformUp

func (j *InnerJoin) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type InsertInto

type InsertInto struct {
	BinaryNode
	Columns []string
}

InsertInto is a node describing the insertion into some table.

func NewInsertInto

func NewInsertInto(dst, src sql.Node, cols []string) *InsertInto

NewInsertInto creates an InsertInto node.

func (*InsertInto) Execute

func (p *InsertInto) Execute(ctx *sql.Context) (int, error)

Execute inserts the rows in the database.

func (*InsertInto) RowIter

func (p *InsertInto) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*InsertInto) Schema

func (p *InsertInto) Schema() sql.Schema

Schema implements the Node interface.

func (InsertInto) String

func (p InsertInto) String() string

func (*InsertInto) TransformExpressionsUp

func (p *InsertInto) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*InsertInto) TransformUp

func (p *InsertInto) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type Limit

type Limit struct {
	UnaryNode
	// contains filtered or unexported fields
}

Limit is a node that only allows up to N rows to be retrieved.

func NewLimit

func NewLimit(size int64, child sql.Node) *Limit

NewLimit creates a new Limit node with the given size.

func (*Limit) Resolved

func (l *Limit) Resolved() bool

Resolved implements the Resolvable interface.

func (*Limit) RowIter

func (l *Limit) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (Limit) String

func (l Limit) String() string

func (*Limit) TransformExpressionsUp

func (l *Limit) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Limit) TransformUp

func (l *Limit) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type NaturalJoin

type NaturalJoin struct {
	BinaryNode
}

NaturalJoin is a join that automatically joins by all the columns with the same name. NaturalJoin is a placeholder node, it should be transformed into an INNER JOIN during analysis.

func NewNaturalJoin

func NewNaturalJoin(left, right sql.Node) *NaturalJoin

NewNaturalJoin returns a new NaturalJoin node.

func (NaturalJoin) Resolved

func (NaturalJoin) Resolved() bool

Resolved implements the Node interface.

func (NaturalJoin) RowIter

func (NaturalJoin) RowIter(*sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (NaturalJoin) Schema

func (NaturalJoin) Schema() sql.Schema

Schema implements the Node interface.

func (NaturalJoin) String

func (j NaturalJoin) String() string

func (*NaturalJoin) TransformExpressionsUp

func (j *NaturalJoin) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*NaturalJoin) TransformUp

func (j *NaturalJoin) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Node interface.

type NullOrdering

type NullOrdering byte

NullOrdering represents how to order based on null values.

const (
	// NullsFirst puts the null values before any other values.
	NullsFirst NullOrdering = iota
	// NullsLast puts the null values after all other values.
	NullsLast NullOrdering = 2
)

type Offset

type Offset struct {
	UnaryNode
	// contains filtered or unexported fields
}

Offset is a node that skips the first N rows.

func NewOffset

func NewOffset(n int64, child sql.Node) *Offset

NewOffset creates a new Offset node.

func (*Offset) Resolved

func (o *Offset) Resolved() bool

Resolved implements the Resolvable interface.

func (*Offset) RowIter

func (o *Offset) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (Offset) String

func (o Offset) String() string

func (*Offset) TransformExpressionsUp

func (o *Offset) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Offset) TransformUp

func (o *Offset) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type OrderedDistinct

type OrderedDistinct struct {
	UnaryNode
}

OrderedDistinct is a Distinct node optimized for sorted row sets. It's 2 orders of magnitude faster and uses 2 orders of magnitude less mem.

func NewOrderedDistinct

func NewOrderedDistinct(child sql.Node) *OrderedDistinct

NewOrderedDistinct creates a new OrderedDistinct node.

func (*OrderedDistinct) Resolved

func (d *OrderedDistinct) Resolved() bool

Resolved implements the Resolvable interface.

func (*OrderedDistinct) RowIter

func (d *OrderedDistinct) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (OrderedDistinct) String

func (d OrderedDistinct) String() string

func (*OrderedDistinct) TransformExpressionsUp

func (d *OrderedDistinct) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*OrderedDistinct) TransformUp

func (d *OrderedDistinct) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type Project

type Project struct {
	UnaryNode
	// Expression projected.
	Projections []sql.Expression
}

Project is a projection of certain expression from the children node.

func NewProject

func NewProject(expressions []sql.Expression, child sql.Node) *Project

NewProject creates a new projection.

func (*Project) Expressions

func (p *Project) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*Project) Resolved

func (p *Project) Resolved() bool

Resolved implements the Resolvable interface.

func (*Project) RowIter

func (p *Project) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*Project) Schema

func (p *Project) Schema() sql.Schema

Schema implements the Node interface.

func (*Project) String

func (p *Project) String() string

func (*Project) TransformExpressions

func (p *Project) TransformExpressions(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*Project) TransformExpressionsUp

func (p *Project) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Project) TransformUp

func (p *Project) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type PushdownProjectionAndFiltersTable

type PushdownProjectionAndFiltersTable struct {
	sql.PushdownProjectionAndFiltersTable
	Columns []sql.Expression
	Filters []sql.Expression
}

PushdownProjectionAndFiltersTable is a node wrapping a table implementing the sql.PushdownProjectionAndFiltersTable interface so it returns a RowIter with custom logic given the set of used columns that need to be projected and the filters that apply to that table. PushdownProjectionAndFiltersTable nodes don't propagate transformations.

func NewPushdownProjectionAndFiltersTable

func NewPushdownProjectionAndFiltersTable(
	columns []sql.Expression,
	filters []sql.Expression,
	table sql.PushdownProjectionAndFiltersTable,
) *PushdownProjectionAndFiltersTable

NewPushdownProjectionAndFiltersTable creates a new PushdownProjectionAndFiltersTable node.

func (*PushdownProjectionAndFiltersTable) Expressions

Expressions implements the Expressioner interface.

func (*PushdownProjectionAndFiltersTable) RowIter

RowIter implements the Node interface.

func (*PushdownProjectionAndFiltersTable) String

func (*PushdownProjectionAndFiltersTable) TransformExpressions

func (t *PushdownProjectionAndFiltersTable) TransformExpressions(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*PushdownProjectionAndFiltersTable) TransformExpressionsUp

func (t *PushdownProjectionAndFiltersTable) TransformExpressionsUp(
	f sql.TransformExprFunc,
) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*PushdownProjectionAndFiltersTable) TransformUp

TransformUp implements the Node interface.

type PushdownProjectionTable

type PushdownProjectionTable struct {
	sql.PushdownProjectionTable
	Columns []string
}

PushdownProjectionTable is a node wrapping a table implementing the sql.PushdownProjectionTable interface so it returns a RowIter with custom logic given the set of used columns that need to be projected. PushdownProjectionTable nodes don't propagate transformations.

func NewPushdownProjectionTable

func NewPushdownProjectionTable(
	columns []string,
	table sql.PushdownProjectionTable,
) *PushdownProjectionTable

NewPushdownProjectionTable creates a new PushdownProjectionTable node.

func (*PushdownProjectionTable) RowIter

func (t *PushdownProjectionTable) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (PushdownProjectionTable) String

func (t PushdownProjectionTable) String() string

func (*PushdownProjectionTable) TransformExpressionsUp

func (t *PushdownProjectionTable) TransformExpressionsUp(
	f sql.TransformExprFunc,
) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*PushdownProjectionTable) TransformUp

TransformUp implements the Node interface.

type ShowTables

type ShowTables struct {
	Database sql.Database
}

ShowTables is a node that shows the database tables.

func NewShowTables

func NewShowTables(database sql.Database) *ShowTables

NewShowTables creates a new show tables node given a database.

func (*ShowTables) Children

func (*ShowTables) Children() []sql.Node

Children implements the Node interface.

func (*ShowTables) Resolved

func (p *ShowTables) Resolved() bool

Resolved implements the Resolvable interface.

func (*ShowTables) RowIter

func (p *ShowTables) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*ShowTables) Schema

func (*ShowTables) Schema() sql.Schema

Schema implements the Node interface.

func (ShowTables) String

func (p ShowTables) String() string

func (*ShowTables) TransformExpressionsUp

func (p *ShowTables) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*ShowTables) TransformUp

func (p *ShowTables) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type Sort

type Sort struct {
	UnaryNode
	SortFields []SortField
}

Sort is the sort node.

func NewSort

func NewSort(sortFields []SortField, child sql.Node) *Sort

NewSort creates a new Sort node.

func (*Sort) Expressions

func (s *Sort) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*Sort) Resolved

func (s *Sort) Resolved() bool

Resolved implements the Resolvable interface.

func (*Sort) RowIter

func (s *Sort) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*Sort) String

func (s *Sort) String() string

func (*Sort) TransformExpressions

func (s *Sort) TransformExpressions(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*Sort) TransformExpressionsUp

func (s *Sort) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Sort) TransformUp

func (s *Sort) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type SortField

type SortField struct {
	// Column to order by.
	Column sql.Expression
	// Order type.
	Order SortOrder
	// NullOrdering defining how nulls will be ordered.
	NullOrdering NullOrdering
}

SortField is a field by which the query will be sorted.

type SortOrder

type SortOrder byte

SortOrder represents the order of the sort (ascending or descending).

const (
	// Ascending order.
	Ascending SortOrder = 1
	// Descending order.
	Descending SortOrder = 2
)

func (SortOrder) String

func (s SortOrder) String() string

type SubqueryAlias

type SubqueryAlias struct {
	UnaryNode
	// contains filtered or unexported fields
}

SubqueryAlias is a node that gives a subquery a name.

func NewSubqueryAlias

func NewSubqueryAlias(name string, node sql.Node) *SubqueryAlias

NewSubqueryAlias creates a new SubqueryAlias node.

func (*SubqueryAlias) Name

func (n *SubqueryAlias) Name() string

Name implements the Table interface.

func (*SubqueryAlias) RowIter

func (n *SubqueryAlias) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*SubqueryAlias) Schema

func (n *SubqueryAlias) Schema() sql.Schema

Schema implements the Node interface.

func (SubqueryAlias) String

func (n SubqueryAlias) String() string

func (*SubqueryAlias) TransformExpressionsUp

func (n *SubqueryAlias) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Node interface.

func (*SubqueryAlias) TransformUp

func (n *SubqueryAlias) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Node interface.

type TableAlias

type TableAlias struct {
	*UnaryNode
	// contains filtered or unexported fields
}

TableAlias is a node that acts as a table with a given name.

func NewTableAlias

func NewTableAlias(name string, node sql.Node) *TableAlias

NewTableAlias returns a new Table alias node.

func (*TableAlias) Name

func (t *TableAlias) Name() string

Name implements the Nameable interface.

func (*TableAlias) RowIter

func (t *TableAlias) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (TableAlias) String

func (t TableAlias) String() string

func (*TableAlias) TransformExpressionsUp

func (t *TableAlias) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*TableAlias) TransformUp

func (t *TableAlias) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type UnaryNode

type UnaryNode struct {
	Child sql.Node
}

UnaryNode is a node that has only one children.

func (UnaryNode) Children

func (n UnaryNode) Children() []sql.Node

Children implements the Node interface.

func (UnaryNode) Resolved

func (n UnaryNode) Resolved() bool

Resolved implements the Resolvable interface.

func (*UnaryNode) Schema

func (n *UnaryNode) Schema() sql.Schema

Schema implements the Node interface.

type UnresolvedTable

type UnresolvedTable struct {
	// Name of the table.
	Name string
}

UnresolvedTable is a table that has not been resolved yet but whose name is known.

func NewUnresolvedTable

func NewUnresolvedTable(name string) *UnresolvedTable

NewUnresolvedTable creates a new Unresolved table.

func (*UnresolvedTable) Children

func (*UnresolvedTable) Children() []sql.Node

Children implements the Node interface.

func (*UnresolvedTable) Resolved

func (*UnresolvedTable) Resolved() bool

Resolved implements the Resolvable interface.

func (*UnresolvedTable) RowIter

func (*UnresolvedTable) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the RowIter interface.

func (*UnresolvedTable) Schema

func (*UnresolvedTable) Schema() sql.Schema

Schema implements the Node interface.

func (UnresolvedTable) String

func (t UnresolvedTable) String() string

func (*UnresolvedTable) TransformExpressionsUp

func (t *UnresolvedTable) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*UnresolvedTable) TransformUp

func (t *UnresolvedTable) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type Values

type Values struct {
	ExpressionTuples [][]sql.Expression
}

Values represents a set of tuples of expressions.

func NewValues

func NewValues(tuples [][]sql.Expression) *Values

NewValues creates a Values node with the given tuples.

func (*Values) Children

func (p *Values) Children() []sql.Node

Children implements the Node interface.

func (*Values) Expressions

func (p *Values) Expressions() []sql.Expression

Expressions implements the Expressioner interface.

func (*Values) Resolved

func (p *Values) Resolved() bool

Resolved implements the Resolvable interface.

func (*Values) RowIter

func (p *Values) RowIter(ctx *sql.Context) (sql.RowIter, error)

RowIter implements the Node interface.

func (*Values) Schema

func (p *Values) Schema() sql.Schema

Schema implements the Node interface.

func (*Values) String

func (p *Values) String() string

func (*Values) TransformExpressions

func (p *Values) TransformExpressions(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressions implements the Expressioner interface.

func (*Values) TransformExpressionsUp

func (p *Values) TransformExpressionsUp(f sql.TransformExprFunc) (sql.Node, error)

TransformExpressionsUp implements the Transformable interface.

func (*Values) TransformUp

func (p *Values) TransformUp(f sql.TransformNodeFunc) (sql.Node, error)

TransformUp implements the Transformable interface.

type Visitor

type Visitor interface {
	// Visit method is invoked for each node encountered by Walk.
	// If the result Visitor is not nul, Walk visits each of the children
	// of the node with that visitor, followed by a call of Visit(nil)
	// to the returned visitor.
	Visit(node sql.Node) Visitor
}

Visitor visits nodes in the plan.

Jump to

Keyboard shortcuts

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