// Build builds the ast node to a Plan.
Build builds the ast node to a Plan.
// Build builds the ast node to a Plan .
func (b *PlanBuilder) Build(ctx context.Context, node ast.Node) (Plan, error) {
	b.optFlag |= flagPrunColumns
	switch x := node.(type) {
	case *ast.AdminStmt:
		return b.buildAdmin(ctx, x)
	case *ast.DeallocateStmt:
		return &Deallocate{Name: x.Name}, nil
	case *ast.DeleteStmt:
		return b.buildDelete(ctx, x)
	case *ast.ExecuteStmt:
		return b.buildExecute(ctx, x)
	case *ast.ExplainStmt:
		return b.buildExplain(ctx, x)
	case *ast.ExplainForStmt:
		return b.buildExplainFor(x)
	case *ast.TraceStmt:
		return b.buildTrace(x)
	case *ast.InsertStmt:
		return b.buildInsert(ctx, x)
	case *ast.LoadDataStmt:
		return b.buildLoadData(ctx, x)
	case *ast.LoadStatsStmt:
		return b.buildLoadStats(x), nil
	case *ast.IndexAdviseStmt:
		return b.buildIndexAdvise(x), nil
	case *ast.PrepareStmt:
		return b.buildPrepare(x), nil
	case *ast.SelectStmt:
		if x.SelectIntoOpt != nil {
			return b.buildSelectInto(ctx, x)
		}
		return b.buildSelect(ctx, x)
	case *ast.SetOprStmt:
		return b.buildSetOpr(ctx, x)
	case *ast.UpdateStmt:
		return b.buildUpdate(ctx, x)
	case *ast.ShowStmt:
		return b.buildShow(ctx, x)
	case *ast.DoStmt:
		return b.buildDo(ctx, x)
	case *ast.SetStmt:
		return b.buildSet(ctx, x)
	case *ast.SetConfigStmt:
		return b.buildSetConfig(ctx, x)
	case *ast.AnalyzeTableStmt:
		return b.buildAnalyze(x)
	case *ast.BinlogStmt, *ast.FlushStmt, *ast.UseStmt, *ast.BRIEStmt,
		*ast.BeginStmt, *ast.CommitStmt, *ast.RollbackStmt, *ast.CreateUserStmt, *ast.SetPwdStmt, *ast.AlterInstanceStmt,
		*ast.GrantStmt, *ast.DropUserStmt, *ast.AlterUserStmt, *ast.RevokeStmt, *ast.KillStmt, *ast.DropStatsStmt,
		*ast.GrantRoleStmt, *ast.RevokeRoleStmt, *ast.SetRoleStmt, *ast.SetDefaultRoleStmt, *ast.ShutdownStmt,
		*ast.CreateStatisticsStmt, *ast.DropStatisticsStmt:
		return b.buildSimple(node.(ast.StmtNode))
	case ast.DDLNode:
		return b.buildDDL(ctx, x)
	case *ast.CreateBindingStmt:
		return b.buildCreateBindPlan(x)
	case *ast.DropBindingStmt:
		return b.buildDropBindPlan(x)
	case *ast.ChangeStmt:
		return b.buildChange(x)
	case *ast.SplitRegionStmt:
		return b.buildSplitRegion(x)
	}
	return nil, ErrUnsupportedType.GenWithStack("Unsupported type %T", node)
}
func ( b * PlanBuilder ) Build ( ctx context . Context , node ast . Node ) ( Plan , error ) { b . optFlag |= flagPrunColumns switch x := node . ( type ) { case * ast . AdminStmt : return b . buildAdmin ( ctx , x ) case * ast . DeallocateStmt : return & Deallocate { Name : x . Name } , nil case * ast . DeleteStmt : return b . buildDelete ( ctx , x ) case * ast . ExecuteStmt : return b . buildExecute ( ctx , x ) case * ast . ExplainStmt : return b . buildExplain ( ctx , x ) case * ast . ExplainForStmt : return b . buildExplainFor ( x ) case * ast . TraceStmt : return b . buildTrace ( x ) case * ast . InsertStmt : return b . buildInsert ( ctx , x ) case * ast . LoadDataStmt : return b . buildLoadData ( ctx , x ) case * ast . LoadStatsStmt : return b . buildLoadStats ( x ) , nil case * ast . IndexAdviseStmt : return b . buildIndexAdvise ( x ) , nil case * ast . PrepareStmt : return b . buildPrepare ( x ) , nil case * ast . SelectStmt : if x . SelectIntoOpt != nil { return b . buildSelectInto ( ctx , x ) } return b . buildSelect ( ctx , x ) case * ast . SetOprStmt : return b . buildSetOpr ( ctx , x ) case * ast . UpdateStmt : return b . buildUpdate ( ctx , x ) case * ast . ShowStmt : return b . buildShow ( ctx , x ) case * ast . DoStmt : return b . buildDo ( ctx , x ) case * ast . SetStmt : return b . buildSet ( ctx , x ) case * ast . SetConfigStmt : return b . buildSetConfig ( ctx , x ) case * ast . AnalyzeTableStmt : return b . buildAnalyze ( x ) case * ast . BinlogStmt , * ast . FlushStmt , * ast . UseStmt , * ast . BRIEStmt , * ast . BeginStmt , * ast . CommitStmt , * ast . RollbackStmt , * ast . CreateUserStmt , * ast . SetPwdStmt , * ast . AlterInstanceStmt , * ast . GrantStmt , * ast . DropUserStmt , * ast . AlterUserStmt , * ast . RevokeStmt , * ast . KillStmt , * ast . DropStatsStmt , * ast . GrantRoleStmt , * ast . RevokeRoleStmt , * ast . SetRoleStmt , * ast . SetDefaultRoleStmt , * ast . ShutdownStmt , * ast . CreateStatisticsStmt , * ast . DropStatisticsStmt : return b . buildSimple ( node . ( ast . StmtNode ) ) case ast . DDLNode : return b . buildDDL ( ctx , x ) case * ast . CreateBindingStmt : return b . buildCreateBindPlan ( x ) case * ast . DropBindingStmt : return b . buildDropBindPlan ( x ) case * ast . ChangeStmt : return b . buildChange ( x ) case * ast . SplitRegionStmt : return b . buildSplitRegion ( x ) } return nil , ErrUnsupportedType . GenWithStack ( " " , node ) }
Build builds the ast node to a Plan.
Build builds the ast node to a Plan .