Documentation ¶
Index ¶
- Variables
- func AddSelection(p LogicalPlan, child LogicalPlan, conditions []expression.Expression, ...)
- func BuildChildCtx(d Dialect, in LogicalPlan) (*runSqlCtx, error)
- func CheckAggFuncArgInGroupByItems(p LogicalPlan) error
- func CheckPrivilege(activeRoles []*auth.RoleIdentity, pm privilege.Manager, vs []visitInfo) error
- func DeriveOtherConditions(p *LogicalJoin, deriveLeft bool, deriveRight bool) (leftCond []expression.Expression, rightCond []expression.Expression)
- func DrawLogicalPlan(lp LogicalPlan) string
- func ExprsHasSideEffects(exprs []expression.Expression) bool
- func InPrepare(p *preprocessor)
- func InTxnRetry(p *preprocessor)
- func NewRunSqlCtx() *runSqlCtx
- func Preprocess(ctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema, ...) error
- func ReplaceColumnOfExpr(expr expression.Expression, proj *LogicalProjection, schema *expression.Schema) expression.Expression
- func ReplaceTableNameInSQL(sql string, dialect format.Dialect, restoreFlags format.RestoreFlags, ...) (newSql string, err error)
- func ResolveExprAndReplace(origin expression.Expression, replace map[string]*expression.Column)
- func RewriteSQLFromLP(lp LogicalPlan, m map[DbTable]DbTable, needRewrite bool) (sql string, newTableRefs []string, err error)
- func ToString(p Plan) string
- type AggregateFuncExtractor
- type ByItems
- type CVSDBDialect
- type ClauseType
- type DBType
- type DDL
- type DataSource
- func (p *DataSource) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (ds DataSource) Init(ctx sessionctx.Context, offset int) *DataSource
- func (s *DataSource) OutputNames() types.NameSlice
- func (ds *DataSource) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
- func (ds *DataSource) PruneColumns(parentUsedCols []*expression.Column) error
- func (s *DataSource) Schema() *expression.Schema
- func (s *DataSource) SetOutputNames(names types.NameSlice)
- func (s *DataSource) SetSchema(schema *expression.Schema)
- func (p *DataSource) SqlStmt(d Dialect) (*runSqlCtx, error)
- func (ds *DataSource) TableInfo() *model.TableInfo
- type DbTable
- type DbTableRewriter
- type DbTableVisitor
- type Dialect
- type Explain
- type FrameBound
- type InsertTableOption
- type JoinType
- type LogicalAggregation
- func (p *LogicalAggregation) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (la *LogicalAggregation) GetGroupByCols() []*expression.Column
- func (la LogicalAggregation) Init(ctx sessionctx.Context, offset int) *LogicalAggregation
- func (s *LogicalAggregation) OutputNames() types.NameSlice
- func (la *LogicalAggregation) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
- func (la *LogicalAggregation) PruneColumns(parentUsedCols []*expression.Column) error
- func (s *LogicalAggregation) Schema() *expression.Schema
- func (s *LogicalAggregation) SetOutputNames(names types.NameSlice)
- func (s *LogicalAggregation) SetSchema(schema *expression.Schema)
- func (p *LogicalAggregation) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalApply
- func (la LogicalApply) Init(ctx sessionctx.Context, offset int) *LogicalApply
- func (s *LogicalApply) OutputNames() types.NameSlice
- func (la *LogicalApply) PruneColumns(parentUsedCols []*expression.Column) error
- func (s *LogicalApply) Schema() *expression.Schema
- func (s *LogicalApply) SetOutputNames(names types.NameSlice)
- func (s *LogicalApply) SetSchema(schema *expression.Schema)
- func (p *LogicalApply) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalJoin
- func (p *LogicalJoin) AppendJoinConds(eq []*expression.ScalarFunction, left, right, other []expression.Expression)
- func (p *LogicalJoin) AttachOnConds(onConds []expression.Expression)
- func (p *LogicalJoin) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p *LogicalJoin) ExtractOnCondition(conditions []expression.Expression, leftSchema *expression.Schema, ...) (eqCond []*expression.ScalarFunction, leftCond []expression.Expression, ...)
- func (p LogicalJoin) Init(ctx sessionctx.Context, offset int) *LogicalJoin
- func (s *LogicalJoin) OutputNames() types.NameSlice
- func (p *LogicalJoin) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
- func (p *LogicalJoin) PruneColumns(parentUsedCols []*expression.Column) error
- func (s *LogicalJoin) Schema() *expression.Schema
- func (s *LogicalJoin) SetOutputNames(names types.NameSlice)
- func (s *LogicalJoin) SetSchema(schema *expression.Schema)
- func (p *LogicalJoin) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalLimit
- func (p *LogicalLimit) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p *LogicalLimit) Children() []LogicalPlan
- func (p *LogicalLimit) ExplainInfo() string
- func (p *LogicalLimit) HashCode() []byte
- func (p LogicalLimit) Init(ctx sessionctx.Context, offset int) *LogicalLimit
- func (p *LogicalLimit) OutputNames() types.NameSlice
- func (p *LogicalLimit) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
- func (p *LogicalLimit) PruneColumns(parentUsedCols []*expression.Column) error
- func (p *LogicalLimit) Schema() *expression.Schema
- func (p *LogicalLimit) SetChild(i int, child LogicalPlan)
- func (p *LogicalLimit) SetChildren(children ...LogicalPlan)
- func (p *LogicalLimit) SetOutputNames(names types.NameSlice)
- func (p *LogicalLimit) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalMaxOneRow
- func (p *LogicalMaxOneRow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p *LogicalMaxOneRow) Children() []LogicalPlan
- func (p *LogicalMaxOneRow) ExplainInfo() string
- func (p *LogicalMaxOneRow) HashCode() []byte
- func (p LogicalMaxOneRow) Init(ctx sessionctx.Context, offset int) *LogicalMaxOneRow
- func (p *LogicalMaxOneRow) OutputNames() types.NameSlice
- func (p *LogicalMaxOneRow) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
- func (p *LogicalMaxOneRow) PruneColumns(parentUsedCols []*expression.Column) error
- func (p *LogicalMaxOneRow) Schema() *expression.Schema
- func (p *LogicalMaxOneRow) SetChild(i int, child LogicalPlan)
- func (p *LogicalMaxOneRow) SetChildren(children ...LogicalPlan)
- func (p *LogicalMaxOneRow) SetOutputNames(names types.NameSlice)
- func (p *LogicalMaxOneRow) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalPlan
- type LogicalProjection
- func (p *LogicalProjection) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p LogicalProjection) Init(ctx sessionctx.Context, offset int) *LogicalProjection
- func (s *LogicalProjection) OutputNames() types.NameSlice
- func (p *LogicalProjection) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
- func (p *LogicalProjection) PruneColumns(parentUsedCols []*expression.Column) error
- func (s *LogicalProjection) Schema() *expression.Schema
- func (s *LogicalProjection) SetOutputNames(names types.NameSlice)
- func (s *LogicalProjection) SetSchema(schema *expression.Schema)
- func (p *LogicalProjection) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalSelection
- func (p *LogicalSelection) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p *LogicalSelection) Children() []LogicalPlan
- func (p *LogicalSelection) ExplainInfo() string
- func (p *LogicalSelection) HashCode() []byte
- func (p LogicalSelection) Init(ctx sessionctx.Context, offset int) *LogicalSelection
- func (p *LogicalSelection) OutputNames() types.NameSlice
- func (p *LogicalSelection) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
- func (p *LogicalSelection) PruneColumns(parentUsedCols []*expression.Column) error
- func (p *LogicalSelection) Schema() *expression.Schema
- func (p *LogicalSelection) SetChild(i int, child LogicalPlan)
- func (p *LogicalSelection) SetChildren(children ...LogicalPlan)
- func (p *LogicalSelection) SetOutputNames(names types.NameSlice)
- func (p *LogicalSelection) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalShow
- func (p *LogicalShow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p LogicalShow) Init(ctx sessionctx.Context) *LogicalShow
- func (s *LogicalShow) OutputNames() types.NameSlice
- func (s *LogicalShow) Schema() *expression.Schema
- func (s *LogicalShow) SetOutputNames(names types.NameSlice)
- func (s *LogicalShow) SetSchema(schema *expression.Schema)
- type LogicalSort
- func (p *LogicalSort) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p *LogicalSort) Children() []LogicalPlan
- func (p *LogicalSort) ExplainInfo() string
- func (p *LogicalSort) HashCode() []byte
- func (ls LogicalSort) Init(ctx sessionctx.Context, offset int) *LogicalSort
- func (p *LogicalSort) OutputNames() types.NameSlice
- func (p *LogicalSort) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
- func (ls *LogicalSort) PruneColumns(parentUsedCols []*expression.Column) error
- func (p *LogicalSort) Schema() *expression.Schema
- func (p *LogicalSort) SetChild(i int, child LogicalPlan)
- func (p *LogicalSort) SetChildren(children ...LogicalPlan)
- func (p *LogicalSort) SetOutputNames(names types.NameSlice)
- func (p *LogicalSort) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalTableDual
- func (p *LogicalTableDual) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p LogicalTableDual) Init(ctx sessionctx.Context, offset int) *LogicalTableDual
- func (s *LogicalTableDual) OutputNames() types.NameSlice
- func (s *LogicalTableDual) Schema() *expression.Schema
- func (s *LogicalTableDual) SetOutputNames(names types.NameSlice)
- func (s *LogicalTableDual) SetSchema(schema *expression.Schema)
- type LogicalTableScan
- func (p *LogicalTableScan) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (ts LogicalTableScan) Init(ctx sessionctx.Context, offset int) *LogicalTableScan
- func (s *LogicalTableScan) OutputNames() types.NameSlice
- func (s *LogicalTableScan) Schema() *expression.Schema
- func (s *LogicalTableScan) SetOutputNames(names types.NameSlice)
- func (s *LogicalTableScan) SetSchema(schema *expression.Schema)
- type LogicalUnionAll
- func (p *LogicalUnionAll) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p LogicalUnionAll) Init(ctx sessionctx.Context, offset int) *LogicalUnionAll
- func (s *LogicalUnionAll) OutputNames() types.NameSlice
- func (p *LogicalUnionAll) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
- func (p *LogicalUnionAll) PruneColumns(parentUsedCols []*expression.Column) error
- func (s *LogicalUnionAll) Schema() *expression.Schema
- func (s *LogicalUnionAll) SetOutputNames(names types.NameSlice)
- func (s *LogicalUnionAll) SetSchema(schema *expression.Schema)
- func (p *LogicalUnionAll) SqlStmt(d Dialect) (*runSqlCtx, error)
- type LogicalWindow
- func (p *LogicalWindow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
- func (p *LogicalWindow) GetPartitionByCols() []*expression.Column
- func (p *LogicalWindow) GetWindowResultColumns() []*expression.Column
- func (p LogicalWindow) Init(ctx sessionctx.Context, offset int) *LogicalWindow
- func (s *LogicalWindow) OutputNames() types.NameSlice
- func (p *LogicalWindow) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
- func (p *LogicalWindow) PruneColumns(parentUsedCols []*expression.Column) error
- func (s *LogicalWindow) Schema() *expression.Schema
- func (s *LogicalWindow) SetOutputNames(names types.NameSlice)
- func (s *LogicalWindow) SetSchema(schema *expression.Schema)
- func (p *LogicalWindow) SqlStmt(d Dialect) (*runSqlCtx, error)
- type MySQLDialect
- type OdpsDialect
- type Plan
- type PlanBuilder
- func (b *PlanBuilder) Build(ctx context.Context, node ast.Node) (Plan, error)
- func (b *PlanBuilder) BuildDataSourceFromView(ctx context.Context, dbName model.CIStr, tableInfo *model.TableInfo) (LogicalPlan, error)
- func (b *PlanBuilder) GetOptFlag() uint64
- func (b *PlanBuilder) GetVisitInfo() []visitInfo
- func (b *PlanBuilder) TableHints() *tableHintInfo
- type PostgresDialect
- type PreprocessOpt
- type Set
- type ShowContents
- type Simple
- type WindowFrame
- type WindowFuncExtractor
Constants ¶
This section is empty.
Variables ¶
var ( ErrUnknown = terror.ClassOptimizer.New(mysql.ErrUnknown, mysql.MySQLErrName[mysql.ErrUnknown]) ErrUnknownColumn = terror.ClassOptimizer.New(mysql.ErrBadField, mysql.MySQLErrName[mysql.ErrBadField]) ErrAmbiguous = terror.ClassOptimizer.New(mysql.ErrNonUniq, mysql.MySQLErrName[mysql.ErrNonUniq]) ErrUnsupportedType = terror.ClassOptimizer.New(mysql.ErrUnsupportedType, mysql.MySQLErrName[mysql.ErrUnsupportedType]) ErrDupFieldName = terror.ClassOptimizer.New(mysql.ErrDupFieldName, mysql.MySQLErrName[mysql.ErrDupFieldName]) ErrInvalidWildCard = terror.ClassOptimizer.New(mysql.ErrInvalidWildCard, mysql.MySQLErrName[mysql.ErrInvalidWildCard]) ErrNoDB = terror.ClassOptimizer.New(mysql.ErrNoDB, mysql.MySQLErrName[mysql.ErrNoDB]) ErrBadTable = terror.ClassOptimizer.New(mysql.ErrBadTable, mysql.MySQLErrName[mysql.ErrBadTable]) ErrNonUniqTable = terror.ClassOptimizer.New(mysql.ErrNonuniqTable, mysql.MySQLErrName[mysql.ErrNonuniqTable]) ErrIllegalReference = terror.ClassOptimizer.New(mysql.ErrIllegalReference, mysql.MySQLErrName[mysql.ErrIllegalReference]) ErrWrongGroupField = terror.ClassOptimizer.New(mysql.ErrWrongGroupField, mysql.MySQLErrName[mysql.ErrWrongGroupField]) ErrInvalidGroupFuncUse = terror.ClassOptimizer.New(mysql.ErrInvalidGroupFuncUse, mysql.MySQLErrName[mysql.ErrInvalidGroupFuncUse]) ErrWrongUsage = terror.ClassOptimizer.New(mysql.ErrWrongUsage, mysql.MySQLErrName[mysql.ErrWrongUsage]) ErrWindowInvalidWindowFuncAliasUse = terror.ClassOptimizer.New(mysql.ErrWindowInvalidWindowFuncAliasUse, mysql.MySQLErrName[mysql.ErrWindowInvalidWindowFuncAliasUse]) ErrWrongArguments = terror.ClassOptimizer.New(mysql.ErrWrongArguments, mysql.MySQLErrName[mysql.ErrWrongArguments]) ErrTablenameNotAllowedHere = terror.ClassOptimizer.New(mysql.ErrTablenameNotAllowedHere, mysql.MySQLErrName[mysql.ErrTablenameNotAllowedHere]) ErrWrongNumberOfColumnsInSelect = terror.ClassOptimizer.New(mysql.ErrWrongNumberOfColumnsInSelect, mysql.MySQLErrName[mysql.ErrWrongNumberOfColumnsInSelect]) ErrDBaccessDenied = terror.ClassOptimizer.New(mysql.ErrDBaccessDenied, mysql.MySQLErrName[mysql.ErrDBaccessDenied]) ErrTableaccessDenied = terror.ClassOptimizer.New(mysql.ErrTableaccessDenied, mysql.MySQLErrName[mysql.ErrTableaccessDenied]) ErrPrivilegeCheckFail = terror.ClassOptimizer.New(mysql.ErrPrivilegeCheckFail, mysql.MySQLErrName[mysql.ErrPrivilegeCheckFail]) ErrSpecificAccessDenied = terror.ClassOptimizer.New(mysql.ErrSpecificAccessDenied, mysql.MySQLErrName[mysql.ErrSpecificAccessDenied]) ErrViewInvalid = terror.ClassOptimizer.New(mysql.ErrViewInvalid, mysql.MySQLErrName[mysql.ErrViewInvalid]) ErrWindowInvalidWindowFuncUse = terror.ClassOptimizer.New(mysql.ErrWindowInvalidWindowFuncUse, mysql.MySQLErrName[mysql.ErrWindowInvalidWindowFuncUse]) ErrWindowNoSuchWindow = terror.ClassOptimizer.New(mysql.ErrWindowNoSuchWindow, mysql.MySQLErrName[mysql.ErrWindowNoSuchWindow]) ErrWindowCircularityInWindowGraph = terror.ClassOptimizer.New(mysql.ErrWindowCircularityInWindowGraph, mysql.MySQLErrName[mysql.ErrWindowCircularityInWindowGraph]) ErrWindowNoChildPartitioning = terror.ClassOptimizer.New(mysql.ErrWindowNoChildPartitioning, mysql.MySQLErrName[mysql.ErrWindowNoChildPartitioning]) ErrWindowNoInherentFrame = terror.ClassOptimizer.New(mysql.ErrWindowNoInherentFrame, mysql.MySQLErrName[mysql.ErrWindowNoInherentFrame]) ErrWindowNoRedefineOrderBy = terror.ClassOptimizer.New(mysql.ErrWindowNoRedefineOrderBy, mysql.MySQLErrName[mysql.ErrWindowNoRedefineOrderBy]) ErrWindowDuplicateName = terror.ClassOptimizer.New(mysql.ErrWindowDuplicateName, mysql.MySQLErrName[mysql.ErrWindowDuplicateName]) ErrPartitionClauseOnNonpartitioned = terror.ClassOptimizer.New(mysql.ErrPartitionClauseOnNonpartitioned, mysql.MySQLErrName[mysql.ErrPartitionClauseOnNonpartitioned]) ErrWindowFrameStartIllegal = terror.ClassOptimizer.New(mysql.ErrWindowFrameStartIllegal, mysql.MySQLErrName[mysql.ErrWindowFrameStartIllegal]) ErrWindowFrameEndIllegal = terror.ClassOptimizer.New(mysql.ErrWindowFrameEndIllegal, mysql.MySQLErrName[mysql.ErrWindowFrameEndIllegal]) ErrWindowFrameIllegal = terror.ClassOptimizer.New(mysql.ErrWindowFrameIllegal, mysql.MySQLErrName[mysql.ErrWindowFrameIllegal]) ErrWindowRangeFrameOrderType = terror.ClassOptimizer.New(mysql.ErrWindowRangeFrameOrderType, mysql.MySQLErrName[mysql.ErrWindowRangeFrameOrderType]) ErrWindowRangeFrameTemporalType = terror.ClassOptimizer.New(mysql.ErrWindowRangeFrameTemporalType, mysql.MySQLErrName[mysql.ErrWindowRangeFrameTemporalType]) ErrWindowRangeFrameNumericType = terror.ClassOptimizer.New(mysql.ErrWindowRangeFrameNumericType, mysql.MySQLErrName[mysql.ErrWindowRangeFrameNumericType]) ErrWindowRangeBoundNotConstant = terror.ClassOptimizer.New(mysql.ErrWindowRangeBoundNotConstant, mysql.MySQLErrName[mysql.ErrWindowRangeBoundNotConstant]) ErrWindowRowsIntervalUse = terror.ClassOptimizer.New(mysql.ErrWindowRowsIntervalUse, mysql.MySQLErrName[mysql.ErrWindowRowsIntervalUse]) ErrWindowFunctionIgnoresFrame = terror.ClassOptimizer.New(mysql.ErrWindowFunctionIgnoresFrame, mysql.MySQLErrName[mysql.ErrWindowFunctionIgnoresFrame]) ErrNotSupportedYet = terror.ClassOptimizer.New(mysql.ErrNotSupportedYet, mysql.MySQLErrName[mysql.ErrNotSupportedYet]) )
var ( DBDialectMap = map[DBType]Dialect{ DBTypeUnknown: NewMySQLDialect(), DBTypeCSVDB: NewCVSDBDialect(), DBTypeMySQL: NewMySQLDialect(), DBTypePostgres: NewPostgresDialect(), DBTypeSQLite: NewMySQLDialect(), DBTypeODPS: NewOdpsDialect(), } )
Functions ¶
func AddSelection ¶
func AddSelection(p LogicalPlan, child LogicalPlan, conditions []expression.Expression, chIdx int)
func BuildChildCtx ¶
func BuildChildCtx(d Dialect, in LogicalPlan) (*runSqlCtx, error)
func CheckAggFuncArgInGroupByItems ¶
func CheckAggFuncArgInGroupByItems(p LogicalPlan) error
func CheckPrivilege ¶
func CheckPrivilege(activeRoles []*auth.RoleIdentity, pm privilege.Manager, vs []visitInfo) error
CheckPrivilege checks the privilege for a user.
func DeriveOtherConditions ¶
func DeriveOtherConditions(p *LogicalJoin, deriveLeft bool, deriveRight bool) (leftCond []expression.Expression, rightCond []expression.Expression)
DeriveOtherConditions given a LogicalJoin, check the OtherConditions to see if we can derive more conditions for left/right child pushdown.
func DrawLogicalPlan ¶
func DrawLogicalPlan(lp LogicalPlan) string
DrawLogicalPlan draws a logical plan in Graphviz format. One can visualize the returned string at http://www.webgraphviz.com/
func ExprsHasSideEffects ¶
func ExprsHasSideEffects(exprs []expression.Expression) bool
ExprsHasSideEffects checks if any of the expressions has side effects.
func InPrepare ¶
func InPrepare(p *preprocessor)
InPrepare is a PreprocessOpt that indicates preprocess is executing under prepare statement.
func InTxnRetry ¶
func InTxnRetry(p *preprocessor)
InTxnRetry is a PreprocessOpt that indicates preprocess is executing under transaction retry.
func NewRunSqlCtx ¶
func NewRunSqlCtx() *runSqlCtx
func Preprocess ¶
func Preprocess(ctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema, preprocessOpt ...PreprocessOpt) error
Preprocess resolves table names of the node, and checks some statements validation.
func ReplaceColumnOfExpr ¶
func ReplaceColumnOfExpr(expr expression.Expression, proj *LogicalProjection, schema *expression.Schema) expression.Expression
ReplaceColumnOfExpr replaces column of expression by another LogicalProjection.
func ReplaceTableNameInSQL ¶
func ResolveExprAndReplace ¶
func ResolveExprAndReplace(origin expression.Expression, replace map[string]*expression.Column)
ResolveExprAndReplace replaces columns fields of expressions by children logical plans.
func RewriteSQLFromLP ¶
func RewriteSQLFromLP(lp LogicalPlan, m map[DbTable]DbTable, needRewrite bool) (sql string, newTableRefs []string, err error)
RewriteSQLFromLP create sql string from lp with dialect
Types ¶
type AggregateFuncExtractor ¶
type AggregateFuncExtractor struct { // AggFuncs is the collected AggregateFuncExprs. AggFuncs []*ast.AggregateFuncExpr // contains filtered or unexported fields }
AggregateFuncExtractor visits Expr tree. It converts ColunmNameExpr to AggregateFuncExpr and collects AggregateFuncExpr.
type ByItems ¶
type ByItems struct { Expr expression.Expression Desc bool }
ByItems wraps a "by" item.
type CVSDBDialect ¶
type CVSDBDialect struct {
MySQLDialect
}
func NewCVSDBDialect ¶
func NewCVSDBDialect() *CVSDBDialect
func (*CVSDBDialect) GetFormatDialect ¶
func (d *CVSDBDialect) GetFormatDialect() format.Dialect
func (*CVSDBDialect) GetRestoreFlags ¶
func (d *CVSDBDialect) GetRestoreFlags() format.RestoreFlags
func (*CVSDBDialect) SupportAnyValue ¶
func (d *CVSDBDialect) SupportAnyValue() bool
type ClauseType ¶
type ClauseType int
const ( // table source includes join, union, table ClauseTableSource ClauseType = iota ClauseWhere ClauseAggregate ClauseHaving ClauseWindow ClauseProjection ClauseOrderby ClauseLimit )
type DBType ¶
type DBType int
func ParseDBType ¶
type DDL ¶
DDL represents a DDL statement plan.
func (*DDL) OutputNames ¶
OutputNames returns the outputting names of each column.
func (*DDL) Schema ¶
func (s *DDL) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*DDL) SetOutputNames ¶
func (*DDL) SetSchema ¶
func (s *DDL) SetSchema(schema *expression.Schema)
SetSchema implements the Plan.SetSchema interface.
type DataSource ¶
type DataSource struct { Columns []*model.ColumnInfo DBName model.CIStr PartyName model.CIStr TableAsName *model.CIStr // TblCols contains the original columns of table before being pruned, and it // is used for estimating table scan cost. TblCols []*expression.Column // contains filtered or unexported fields }
DataSource represents a tableScan without condition push down.
func (*DataSource) BuildKeyInfo ¶
func (p *DataSource) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (DataSource) Init ¶
func (ds DataSource) Init(ctx sessionctx.Context, offset int) *DataSource
Init initializes DataSource.
func (*DataSource) OutputNames ¶
func (*DataSource) PredicatePushDown ¶
func (ds *DataSource) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
PredicatePushDown implements LogicalPlan PredicatePushDown interface.
func (*DataSource) PruneColumns ¶
func (ds *DataSource) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*DataSource) Schema ¶
func (s *DataSource) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*DataSource) SetOutputNames ¶
func (*DataSource) SetSchema ¶
func (s *DataSource) SetSchema(schema *expression.Schema)
func (*DataSource) SqlStmt ¶
func (p *DataSource) SqlStmt(d Dialect) (*runSqlCtx, error)
func (*DataSource) TableInfo ¶
func (ds *DataSource) TableInfo() *model.TableInfo
TableInfo returns the *TableInfo of data source.
type DbTable ¶
type DbTable struct {
// contains filtered or unexported fields
}
func GetSourceTables ¶
func NewDbTable ¶
func NewDbTableFromString ¶
func (*DbTable) GetTableName ¶
type DbTableRewriter ¶
type DbTableRewriter struct {
// contains filtered or unexported fields
}
replace ref table name by local table name
func NewDbTableRewriter ¶
func NewDbTableRewriter(m map[DbTable]DbTable) *DbTableRewriter
func (*DbTableRewriter) Error ¶
func (r *DbTableRewriter) Error() error
type DbTableVisitor ¶
type DbTableVisitor struct {
// contains filtered or unexported fields
}
replace ref table name by local table name
func NewDbTableVisitor ¶
func NewDbTableVisitor() *DbTableVisitor
func (*DbTableVisitor) Error ¶
func (r *DbTableVisitor) Error() error
func (*DbTableVisitor) Tables ¶
func (r *DbTableVisitor) Tables() []DbTable
type Dialect ¶
type Dialect interface { GetRestoreFlags() format.RestoreFlags GetFormatDialect() format.Dialect SupportAnyValue() bool }
type Explain ¶
type Explain struct { TargetPlan Plan Format string Analyze bool ExecStmt ast.StmtNode Rows [][]string // contains filtered or unexported fields }
Explain represents a explain plan.
func (*Explain) OutputNames ¶
OutputNames returns the outputting names of each column.
func (*Explain) Schema ¶
func (s *Explain) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*Explain) SetOutputNames ¶
func (*Explain) SetSchema ¶
func (s *Explain) SetSchema(schema *expression.Schema)
SetSchema implements the Plan.SetSchema interface.
type FrameBound ¶
type FrameBound struct { Type ast.BoundType UnBounded bool Num uint64 // CalcFuncs is used for range framed windows. // We will build the date_add or date_sub functions for frames like `INTERVAL '2:30' MINUTE_SECOND FOLLOWING`, // and plus or minus for frames like `1 preceding`. CalcFuncs []expression.Expression // CmpFuncs is used to decide whether one row is included in the current frame. CmpFuncs []expression.CompareFunc }
FrameBound is the boundary of a frame.
type InsertTableOption ¶
type JoinType ¶
type JoinType int
const ( // InnerJoin means inner join. InnerJoin JoinType = iota // LeftOuterJoin means left join. LeftOuterJoin // RightOuterJoin means right join. RightOuterJoin // SemiJoin means if row a in table A matches some rows in B, just output a. SemiJoin // AntiSemiJoin means if row a in table A does not match any row in B, then output a. AntiSemiJoin // LeftOuterSemiJoin means if row a in table A matches some rows in B, output (a, true), otherwise, output (a, false). LeftOuterSemiJoin // AntiLeftOuterSemiJoin means if row a in table A matches some rows in B, output (a, false), otherwise, output (a, true). AntiLeftOuterSemiJoin )
func (JoinType) IsOuterJoin ¶
IsOuterJoin returns if this joiner is a outer joiner
type LogicalAggregation ¶
type LogicalAggregation struct { AggFuncs []*aggregation.AggFuncDesc GroupByItems []expression.Expression // LogicalAggregation is produced by `select distinct` ProducedByDistinct bool // contains filtered or unexported fields }
LogicalAggregation represents an aggregate plan.
func (*LogicalAggregation) BuildKeyInfo ¶
func (p *LogicalAggregation) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (*LogicalAggregation) GetGroupByCols ¶
func (la *LogicalAggregation) GetGroupByCols() []*expression.Column
GetGroupByCols returns the groupByCols. If the groupByCols haven't be collected, this method would collect them at first. If the GroupByItems have been changed, we should explicitly collect GroupByColumns before this method.
func (LogicalAggregation) Init ¶
func (la LogicalAggregation) Init(ctx sessionctx.Context, offset int) *LogicalAggregation
Init initializes LogicalAggregation.
func (*LogicalAggregation) OutputNames ¶
func (*LogicalAggregation) PredicatePushDown ¶
func (la *LogicalAggregation) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
PredicatePushDown implements LogicalPlan PredicatePushDown interface.
func (*LogicalAggregation) PruneColumns ¶
func (la *LogicalAggregation) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalAggregation) Schema ¶
func (s *LogicalAggregation) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalAggregation) SetOutputNames ¶
func (*LogicalAggregation) SetSchema ¶
func (s *LogicalAggregation) SetSchema(schema *expression.Schema)
func (*LogicalAggregation) SqlStmt ¶
func (p *LogicalAggregation) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalApply ¶
type LogicalApply struct { LogicalJoin CorCols []*expression.CorrelatedColumn }
LogicalApply gets one row from outer executor and gets one row from inner executor according to outer row.
func (LogicalApply) Init ¶
func (la LogicalApply) Init(ctx sessionctx.Context, offset int) *LogicalApply
Init initializes LogicalApply.
func (*LogicalApply) OutputNames ¶
func (*LogicalApply) PruneColumns ¶
func (la *LogicalApply) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalApply) Schema ¶
func (s *LogicalApply) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalApply) SetOutputNames ¶
func (*LogicalApply) SetSchema ¶
func (s *LogicalApply) SetSchema(schema *expression.Schema)
func (*LogicalApply) SqlStmt ¶
func (p *LogicalApply) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalJoin ¶
type LogicalJoin struct { JoinType JoinType EqualConditions []*expression.ScalarFunction LeftConditions expression.CNFExprs RightConditions expression.CNFExprs OtherConditions expression.CNFExprs LeftJoinKeys []*expression.Column RightJoinKeys []*expression.Column // DefaultValues is only used for left/right outer join, which is values the inner row's should be when the outer table // doesn't match any inner table's row. // That it's nil just means the default values is a slice of NULL. // Currently, only `aggregation push down` phase will set this. DefaultValues []types.Datum // contains filtered or unexported fields }
func (*LogicalJoin) AppendJoinConds ¶
func (p *LogicalJoin) AppendJoinConds(eq []*expression.ScalarFunction, left, right, other []expression.Expression)
AppendJoinConds appends new join conditions.
func (*LogicalJoin) AttachOnConds ¶
func (p *LogicalJoin) AttachOnConds(onConds []expression.Expression)
AttachOnConds extracts on conditions for join and set the `EqualConditions`, `LeftConditions`, `RightConditions` and `OtherConditions` by the result of extract.
func (*LogicalJoin) BuildKeyInfo ¶
func (p *LogicalJoin) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
func (*LogicalJoin) ExtractOnCondition ¶
func (p *LogicalJoin) ExtractOnCondition( conditions []expression.Expression, leftSchema *expression.Schema, rightSchema *expression.Schema, deriveLeft bool, deriveRight bool) (eqCond []*expression.ScalarFunction, leftCond []expression.Expression, rightCond []expression.Expression, otherCond []expression.Expression)
ExtractOnCondition divide conditions in CNF of join node into 4 groups. These conditions can be where conditions, join conditions, or collection of both. If deriveLeft/deriveRight is set, we would try to derive more conditions for left/right plan.
func (LogicalJoin) Init ¶
func (p LogicalJoin) Init(ctx sessionctx.Context, offset int) *LogicalJoin
func (*LogicalJoin) OutputNames ¶
func (*LogicalJoin) PredicatePushDown ¶
func (p *LogicalJoin) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
PredicatePushDown implements LogicalPlan PredicatePushDown interface.
func (*LogicalJoin) PruneColumns ¶
func (p *LogicalJoin) PruneColumns(parentUsedCols []*expression.Column) error
func (*LogicalJoin) Schema ¶
func (s *LogicalJoin) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalJoin) SetOutputNames ¶
func (*LogicalJoin) SetSchema ¶
func (s *LogicalJoin) SetSchema(schema *expression.Schema)
func (*LogicalJoin) SqlStmt ¶
func (p *LogicalJoin) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalLimit ¶
LogicalLimit represents offset and limit plan.
func (*LogicalLimit) BuildKeyInfo ¶
func (p *LogicalLimit) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (*LogicalLimit) Children ¶
func (p *LogicalLimit) Children() []LogicalPlan
func (*LogicalLimit) ExplainInfo ¶
func (p *LogicalLimit) ExplainInfo() string
func (*LogicalLimit) HashCode ¶
func (p *LogicalLimit) HashCode() []byte
HashCode implements LogicalPlan interface.
func (LogicalLimit) Init ¶
func (p LogicalLimit) Init(ctx sessionctx.Context, offset int) *LogicalLimit
Init initializes LogicalLimit.
func (*LogicalLimit) OutputNames ¶
func (*LogicalLimit) PredicatePushDown ¶
func (p *LogicalLimit) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
PredicatePushDown implements LogicalPlan interface.
func (*LogicalLimit) PruneColumns ¶
func (p *LogicalLimit) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalLimit) Schema ¶
func (p *LogicalLimit) Schema() *expression.Schema
Schema implements Plan Schema interface.
func (*LogicalLimit) SetChild ¶
func (p *LogicalLimit) SetChild(i int, child LogicalPlan)
func (*LogicalLimit) SetChildren ¶
func (p *LogicalLimit) SetChildren(children ...LogicalPlan)
func (*LogicalLimit) SetOutputNames ¶
func (*LogicalLimit) SqlStmt ¶
func (p *LogicalLimit) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalMaxOneRow ¶
type LogicalMaxOneRow struct {
// contains filtered or unexported fields
}
LogicalMaxOneRow checks if a query returns no more than one row.
func (*LogicalMaxOneRow) BuildKeyInfo ¶
func (p *LogicalMaxOneRow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (*LogicalMaxOneRow) Children ¶
func (p *LogicalMaxOneRow) Children() []LogicalPlan
func (*LogicalMaxOneRow) ExplainInfo ¶
func (p *LogicalMaxOneRow) ExplainInfo() string
func (*LogicalMaxOneRow) HashCode ¶
func (p *LogicalMaxOneRow) HashCode() []byte
HashCode implements LogicalPlan interface.
func (LogicalMaxOneRow) Init ¶
func (p LogicalMaxOneRow) Init(ctx sessionctx.Context, offset int) *LogicalMaxOneRow
Init initializes LogicalMaxOneRow.
func (*LogicalMaxOneRow) OutputNames ¶
func (*LogicalMaxOneRow) PredicatePushDown ¶
func (p *LogicalMaxOneRow) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
PredicatePushDown implements LogicalPlan interface.
func (*LogicalMaxOneRow) PruneColumns ¶
func (p *LogicalMaxOneRow) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalMaxOneRow) Schema ¶
func (p *LogicalMaxOneRow) Schema() *expression.Schema
Schema implements Plan Schema interface.
func (*LogicalMaxOneRow) SetChild ¶
func (p *LogicalMaxOneRow) SetChild(i int, child LogicalPlan)
func (*LogicalMaxOneRow) SetChildren ¶
func (p *LogicalMaxOneRow) SetChildren(children ...LogicalPlan)
func (*LogicalMaxOneRow) SetOutputNames ¶
type LogicalPlan ¶
type LogicalPlan interface { Plan // HashCode encodes a LogicalPlan to fast compare whether a LogicalPlan equals to another. // We use a strict encode method here which ensures there is no conflict. HashCode() []byte // PredicatePushDown pushes down the predicates in the where/on/having clauses as deeply as possible. // It will accept a predicate that is an expression slice, and return the expressions that can't be pushed. // Because it might change the root if the having clause exists, we need to return a plan that represents a new root. PredicatePushDown([]expression.Expression) ([]expression.Expression, LogicalPlan) // PruneColumns prunes the unused columns. PruneColumns([]*expression.Column) error // BuildKeyInfo will collect the information of unique keys into schema. BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema) // Get all the children. Children() []LogicalPlan // SetChildren sets the children for the plan. SetChildren(...LogicalPlan) // SetChild sets the ith child for the plan. SetChild(i int, child LogicalPlan) SqlStmt(Dialect) (*runSqlCtx, error) // Added for SCQL SetIntoOpt(option *ast.SelectIntoOption) IntoOpt() *ast.SelectIntoOption SetInsertTableOpt(option *InsertTableOption) InsertTableOpt() *InsertTableOption // contains filtered or unexported methods }
func BuildLogicalPlanWithOptimization ¶
func BuildLogicalPlanWithOptimization(ctx context.Context, sctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema) (LogicalPlan, types.NameSlice, error)
BuildLogicalPlanWithOptimization used to build logical plan from ast.Node and optimize it on logical level.
type LogicalProjection ¶
type LogicalProjection struct { Exprs []expression.Expression // CalculateNoDelay indicates this Projection is the root Plan and should be // calculated without delay and will not return any result to client. // Currently it is "true" only when the current sql query is a "DO" statement. // See "https://dev.mysql.com/doc/refman/5.7/en/do.html" for more detail. CalculateNoDelay bool // AvoidColumnEvaluator is a temporary variable which is ONLY used to avoid // building columnEvaluator for the expressions of Projection which is // built by buildProjection4Union. // This can be removed after column pool being supported. // Related issue: TiDB#8141(https://github.com/pingcap/tidb/issues/8141) AvoidColumnEvaluator bool // contains filtered or unexported fields }
func (*LogicalProjection) BuildKeyInfo ¶
func (p *LogicalProjection) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (LogicalProjection) Init ¶
func (p LogicalProjection) Init(ctx sessionctx.Context, offset int) *LogicalProjection
Init initializes LogicalProjection.
func (*LogicalProjection) OutputNames ¶
func (*LogicalProjection) PredicatePushDown ¶
func (p *LogicalProjection) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
PredicatePushDown implements LogicalPlan PredicatePushDown interface.
func (*LogicalProjection) PruneColumns ¶
func (p *LogicalProjection) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalProjection) Schema ¶
func (s *LogicalProjection) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalProjection) SetOutputNames ¶
func (*LogicalProjection) SetSchema ¶
func (s *LogicalProjection) SetSchema(schema *expression.Schema)
func (*LogicalProjection) SqlStmt ¶
func (p *LogicalProjection) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalSelection ¶
type LogicalSelection struct { // Originally the WHERE or ON condition is parsed into a single expression, // but after we converted to CNF(Conjunctive normal form), it can be // split into a list of AND conditions. Conditions []expression.Expression AffectedByGroupThreshold bool // contains filtered or unexported fields }
LogicalSelection represents a where or having predicate.
func (*LogicalSelection) BuildKeyInfo ¶
func (p *LogicalSelection) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (*LogicalSelection) Children ¶
func (p *LogicalSelection) Children() []LogicalPlan
func (*LogicalSelection) ExplainInfo ¶
func (p *LogicalSelection) ExplainInfo() string
func (*LogicalSelection) HashCode ¶
func (p *LogicalSelection) HashCode() []byte
HashCode implements LogicalPlan interface.
func (LogicalSelection) Init ¶
func (p LogicalSelection) Init(ctx sessionctx.Context, offset int) *LogicalSelection
Init initializes LogicalSelection.
func (*LogicalSelection) OutputNames ¶
func (*LogicalSelection) PredicatePushDown ¶
func (p *LogicalSelection) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
PredicatePushDown implements LogicalPlan PredicatePushDown interface.
func (*LogicalSelection) PruneColumns ¶
func (p *LogicalSelection) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalSelection) Schema ¶
func (p *LogicalSelection) Schema() *expression.Schema
Schema implements Plan Schema interface.
func (*LogicalSelection) SetChild ¶
func (p *LogicalSelection) SetChild(i int, child LogicalPlan)
func (*LogicalSelection) SetChildren ¶
func (p *LogicalSelection) SetChildren(children ...LogicalPlan)
func (*LogicalSelection) SetOutputNames ¶
func (*LogicalSelection) SqlStmt ¶
func (p *LogicalSelection) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalShow ¶
type LogicalShow struct { ShowContents // contains filtered or unexported fields }
LogicalShow represents a show plan.
func (*LogicalShow) BuildKeyInfo ¶
func (p *LogicalShow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (LogicalShow) Init ¶
func (p LogicalShow) Init(ctx sessionctx.Context) *LogicalShow
Init initializes LogicalShow.
func (*LogicalShow) OutputNames ¶
func (*LogicalShow) Schema ¶
func (s *LogicalShow) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalShow) SetOutputNames ¶
func (*LogicalShow) SetSchema ¶
func (s *LogicalShow) SetSchema(schema *expression.Schema)
type LogicalSort ¶
type LogicalSort struct { ByItems []*ByItems // contains filtered or unexported fields }
LogicalSort stands for the order by plan.
func (*LogicalSort) BuildKeyInfo ¶
func (p *LogicalSort) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (*LogicalSort) Children ¶
func (p *LogicalSort) Children() []LogicalPlan
func (*LogicalSort) ExplainInfo ¶
func (p *LogicalSort) ExplainInfo() string
func (*LogicalSort) HashCode ¶
func (p *LogicalSort) HashCode() []byte
HashCode implements LogicalPlan interface.
func (LogicalSort) Init ¶
func (ls LogicalSort) Init(ctx sessionctx.Context, offset int) *LogicalSort
Init initializes LogicalSort.
func (*LogicalSort) OutputNames ¶
func (*LogicalSort) PredicatePushDown ¶
func (p *LogicalSort) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
PredicatePushDown implements LogicalPlan interface.
func (*LogicalSort) PruneColumns ¶
func (ls *LogicalSort) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface. If any expression can view as a constant in execution stage, such as correlated column, constant, we do prune them. Note that we can't prune the expressions contain non-deterministic functions, such as rand().
func (*LogicalSort) Schema ¶
func (p *LogicalSort) Schema() *expression.Schema
Schema implements Plan Schema interface.
func (*LogicalSort) SetChild ¶
func (p *LogicalSort) SetChild(i int, child LogicalPlan)
func (*LogicalSort) SetChildren ¶
func (p *LogicalSort) SetChildren(children ...LogicalPlan)
func (*LogicalSort) SetOutputNames ¶
func (*LogicalSort) SqlStmt ¶
func (p *LogicalSort) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalTableDual ¶
type LogicalTableDual struct { RowCount int // contains filtered or unexported fields }
LogicalTableDual represents a dual table plan.
func (*LogicalTableDual) BuildKeyInfo ¶
func (p *LogicalTableDual) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (LogicalTableDual) Init ¶
func (p LogicalTableDual) Init(ctx sessionctx.Context, offset int) *LogicalTableDual
Init initializes LogicalTableDual.
func (*LogicalTableDual) OutputNames ¶
func (*LogicalTableDual) Schema ¶
func (s *LogicalTableDual) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalTableDual) SetOutputNames ¶
func (*LogicalTableDual) SetSchema ¶
func (s *LogicalTableDual) SetSchema(schema *expression.Schema)
type LogicalTableScan ¶
type LogicalTableScan struct { Source *DataSource Ranges []*ranger.Range // contains filtered or unexported fields }
LogicalTableScan is the logical table scan operator.
func (*LogicalTableScan) BuildKeyInfo ¶
func (p *LogicalTableScan) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (LogicalTableScan) Init ¶
func (ts LogicalTableScan) Init(ctx sessionctx.Context, offset int) *LogicalTableScan
Init initializes LogicalTableScan.
func (*LogicalTableScan) OutputNames ¶
func (*LogicalTableScan) Schema ¶
func (s *LogicalTableScan) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalTableScan) SetOutputNames ¶
func (*LogicalTableScan) SetSchema ¶
func (s *LogicalTableScan) SetSchema(schema *expression.Schema)
type LogicalUnionAll ¶
type LogicalUnionAll struct {
// contains filtered or unexported fields
}
LogicalUnionAll represents LogicalUnionAll plan.
func (*LogicalUnionAll) BuildKeyInfo ¶
func (p *LogicalUnionAll) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (LogicalUnionAll) Init ¶
func (p LogicalUnionAll) Init(ctx sessionctx.Context, offset int) *LogicalUnionAll
Init initializes LogicalUnionAll.
func (*LogicalUnionAll) OutputNames ¶
func (*LogicalUnionAll) PredicatePushDown ¶
func (p *LogicalUnionAll) PredicatePushDown(predicates []expression.Expression) (ret []expression.Expression, retPlan LogicalPlan)
PredicatePushDown implements LogicalPlan PredicatePushDown interface.
func (*LogicalUnionAll) PruneColumns ¶
func (p *LogicalUnionAll) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalUnionAll) Schema ¶
func (s *LogicalUnionAll) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalUnionAll) SetOutputNames ¶
func (*LogicalUnionAll) SetSchema ¶
func (s *LogicalUnionAll) SetSchema(schema *expression.Schema)
func (*LogicalUnionAll) SqlStmt ¶
func (p *LogicalUnionAll) SqlStmt(d Dialect) (*runSqlCtx, error)
type LogicalWindow ¶
type LogicalWindow struct { WindowFuncDescs []*aggregation.WindowFuncDesc PartitionBy []property.Item OrderBy []property.Item Frame *WindowFrame // contains filtered or unexported fields }
LogicalWindow represents a logical window function plan.
func (*LogicalWindow) BuildKeyInfo ¶
func (p *LogicalWindow) BuildKeyInfo(selfSchema *expression.Schema, childSchema []*expression.Schema)
BuildKeyInfo implements LogicalPlan BuildKeyInfo interface.
func (*LogicalWindow) GetPartitionByCols ¶
func (p *LogicalWindow) GetPartitionByCols() []*expression.Column
func (*LogicalWindow) GetWindowResultColumns ¶
func (p *LogicalWindow) GetWindowResultColumns() []*expression.Column
GetWindowResultColumns returns the columns storing the result of the window function.
func (LogicalWindow) Init ¶
func (p LogicalWindow) Init(ctx sessionctx.Context, offset int) *LogicalWindow
Init initializes LogicalWindow.
func (*LogicalWindow) OutputNames ¶
func (*LogicalWindow) PredicatePushDown ¶
func (p *LogicalWindow) PredicatePushDown(predicates []expression.Expression) ([]expression.Expression, LogicalPlan)
PredicatePushDown implements LogicalPlan PredicatePushDown interface.
func (*LogicalWindow) PruneColumns ¶
func (p *LogicalWindow) PruneColumns(parentUsedCols []*expression.Column) error
PruneColumns implements LogicalPlan interface.
func (*LogicalWindow) Schema ¶
func (s *LogicalWindow) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*LogicalWindow) SetOutputNames ¶
func (*LogicalWindow) SetSchema ¶
func (s *LogicalWindow) SetSchema(schema *expression.Schema)
func (*LogicalWindow) SqlStmt ¶
func (p *LogicalWindow) SqlStmt(d Dialect) (*runSqlCtx, error)
type MySQLDialect ¶
type MySQLDialect struct {
// contains filtered or unexported fields
}
func NewMySQLDialect ¶
func NewMySQLDialect() *MySQLDialect
func (*MySQLDialect) GetFormatDialect ¶
func (d *MySQLDialect) GetFormatDialect() format.Dialect
func (*MySQLDialect) GetRestoreFlags ¶
func (d *MySQLDialect) GetRestoreFlags() format.RestoreFlags
func (*MySQLDialect) SupportAnyValue ¶
func (d *MySQLDialect) SupportAnyValue() bool
type OdpsDialect ¶
type OdpsDialect struct {
MySQLDialect
}
func NewOdpsDialect ¶
func NewOdpsDialect() *OdpsDialect
func (*OdpsDialect) GetFormatDialect ¶
func (d *OdpsDialect) GetFormatDialect() format.Dialect
func (*OdpsDialect) GetRestoreFlags ¶
func (d *OdpsDialect) GetRestoreFlags() format.RestoreFlags
func (*OdpsDialect) SupportAnyValue ¶
func (d *OdpsDialect) SupportAnyValue() bool
type Plan ¶
type Plan interface { // Get the schema. Schema() *expression.Schema // Get the ID. ID() int // TP get the plan type. TP() string // Get the ID in explain statement ExplainID() fmt.Stringer // ExplainInfo returns operator information to be explained. ExplainInfo() string SCtx() sessionctx.Context // OutputNames returns the outputting names of each column. OutputNames() types.NameSlice // SetOutputNames sets the outputting name by the given slice. SetOutputNames(names types.NameSlice) SelectBlockOffset() int // contains filtered or unexported methods }
func BuildLogicalPlan ¶
func BuildLogicalPlan(ctx context.Context, sctx sessionctx.Context, node ast.Node, is infoschema.InfoSchema) (Plan, types.NameSlice, error)
BuildLogicalPlan used to build logical plan from ast.Node.
type PlanBuilder ¶
type PlanBuilder struct {
// contains filtered or unexported fields
}
PlanBuilder builds Plan from an ast.Node. It just builds the ast node straightforwardly.
func NewPlanBuilder ¶
func NewPlanBuilder(sctx sessionctx.Context, is infoschema.InfoSchema) *PlanBuilder
NewPlanBuilder creates a new PlanBuilder.
func (*PlanBuilder) BuildDataSourceFromView ¶
func (b *PlanBuilder) BuildDataSourceFromView(ctx context.Context, dbName model.CIStr, tableInfo *model.TableInfo) (LogicalPlan, error)
BuildDataSourceFromView is used to build LogicalPlan from view
func (*PlanBuilder) GetOptFlag ¶
func (b *PlanBuilder) GetOptFlag() uint64
GetOptFlag gets the optFlag of the PlanBuilder.
func (*PlanBuilder) GetVisitInfo ¶
func (b *PlanBuilder) GetVisitInfo() []visitInfo
GetVisitInfo gets the visitInfo of the PlanBuilder.
func (*PlanBuilder) TableHints ¶
func (b *PlanBuilder) TableHints() *tableHintInfo
TableHints returns the *tableHintInfo of PlanBuilder.
type PostgresDialect ¶
type PostgresDialect struct {
MySQLDialect
}
func NewPostgresDialect ¶
func NewPostgresDialect() *PostgresDialect
func (*PostgresDialect) GetFormatDialect ¶
func (d *PostgresDialect) GetFormatDialect() format.Dialect
func (*PostgresDialect) GetRestoreFlags ¶
func (d *PostgresDialect) GetRestoreFlags() format.RestoreFlags
func (*PostgresDialect) SupportAnyValue ¶
func (d *PostgresDialect) SupportAnyValue() bool
type PreprocessOpt ¶
type PreprocessOpt func(*preprocessor)
PreprocessOpt presents optional parameters to `Preprocess` method.
type Set ¶
type Set struct { VarAssigns []*expression.VarAssignment // contains filtered or unexported fields }
func (*Set) OutputNames ¶
OutputNames returns the outputting names of each column.
func (*Set) Schema ¶
func (s *Set) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*Set) SetOutputNames ¶
func (*Set) SetSchema ¶
func (s *Set) SetSchema(schema *expression.Schema)
SetSchema implements the Plan.SetSchema interface.
type ShowContents ¶
type ShowContents struct { Tp ast.ShowStmtType // Databases/Tables/Columns/.... DBName string Table *ast.TableName // Used for showing columns. Column *ast.ColumnName // Used for `desc table column`. IndexName model.CIStr Flag int // Some flag parsed from sql, such as FULL. User *auth.UserIdentity // Used for show grants. Roles []*auth.RoleIdentity // Used for show grants. Full bool IfNotExists bool // Used for `show create database if not exists`. GlobalScope bool // Used by show variables. Extended bool // Used for `show extended columns from ...` }
ShowContents stores the contents for the `SHOW` statement.
type Simple ¶
Simple represents a simple statement plan which doesn't need any optimization.
func (*Simple) OutputNames ¶
OutputNames returns the outputting names of each column.
func (*Simple) Schema ¶
func (s *Simple) Schema() *expression.Schema
Schema implements the Plan.Schema interface.
func (*Simple) SetOutputNames ¶
func (*Simple) SetSchema ¶
func (s *Simple) SetSchema(schema *expression.Schema)
SetSchema implements the Plan.SetSchema interface.
type WindowFrame ¶
type WindowFrame struct { Type ast.FrameType Start *FrameBound End *FrameBound }
WindowFrame represents a window function frame.
type WindowFuncExtractor ¶
type WindowFuncExtractor struct {
// contains filtered or unexported fields
}
WindowFuncExtractor visits Expr tree. It converts ColunmNameExpr to WindowFuncExpr and collects WindowFuncExpr.
Source Files ¶
- common_plans.go
- database_dialect.go
- dot.go
- errors.go
- explain.go
- expression_rewriter.go
- hashcode.go
- initialize.go
- logical_plan_builder.go
- logical_plans.go
- logicalplan_to_stmt.go
- logicalplan_to_stmt_helper.go
- optimizer.go
- plan.go
- planbuilder.go
- preprocess.go
- rewrite.go
- rule_aggregation_elimination.go
- rule_aggregation_push_down.go
- rule_build_key_info.go
- rule_column_pruning.go
- rule_eliminate_projection.go
- rule_predicate_push_down.go
- stringer.go
- util.go