func GroupByFromPB(pb *PlanPb) *GroupBy { m := GroupBy{ Stmt: rel.SqlSelectFromPb(pb.GroupBy.Select), } m.PlanBase = NewPlanBase(pb.Parallel) return &m }
func HavingFromPB(pb *PlanPb) *Having { m := Having{ Stmt: rel.SqlSelectFromPb(pb.Having.Select), } m.PlanBase = NewPlanBase(pb.Parallel) return &m }
func WhereFromPB(pb *PlanPb) *Where { m := Where{ Final: pb.Where.Final, Stmt: rel.SqlSelectFromPb(pb.Where.Select), } m.PlanBase = NewPlanBase(pb.Parallel) return &m }
func SelectFromPB(pb *PlanPb, loader SchemaLoader) (*Select, error) { m := Select{ pbplan: pb, ChildDag: true, } m.PlanBase = NewPlanBase(pb.Parallel) if pb.Select != nil { m.Stmt = rel.SqlSelectFromPb(pb.Select.Select) if pb.Select.Context != nil { //u.Infof("got context pb %+v", pb.Select.Context) m.Ctx = NewContextFromPb(pb.Select.Context) m.Ctx.Stmt = m.Stmt m.Ctx.Raw = m.Stmt.Raw sch, err := loader(m.Ctx.SchemaName) if err != nil { u.Errorf("could not load schema: %q err=%v", m.Ctx.SchemaName, err) return nil, err } m.Ctx.Schema = sch } } if len(pb.Children) > 0 { m.tasks = make([]Task, len(pb.Children)) for i, pbt := range pb.Children { //u.Infof("%+v", pbt) childPlan, err := SelectTaskFromTaskPb(pbt, m.Ctx, m.Stmt) if err != nil { u.Errorf("%+v not implemented? %v %#v", pbt, err, pbt) return nil, err } switch cpt := childPlan.(type) { case *Source: m.From = append(m.From, cpt) } m.tasks[i] = childPlan } } return &m, nil }