func Build(stmt algebra.Statement, datastore, systemstore datastore.Datastore, namespace string, subquery bool) (Operator, error) { builder := newBuilder(datastore, systemstore, namespace, subquery) o, err := stmt.Accept(builder) if err != nil { return nil, err } op := o.(Operator) _, is_prepared := o.(*Prepared) if !subquery && !is_prepared { privs, er := stmt.Privileges() if er != nil { return nil, er } if len(privs) > 0 { op = NewAuthorize(privs, op) } return NewSequence(op, NewStream()), nil } else { return op, nil } }
func BuildPrepared(stmt algebra.Statement, datastore, systemstore datastore.Datastore, namespace string, subquery bool) (*Prepared, error) { operator, err := Build(stmt, datastore, systemstore, namespace, subquery) if err != nil { return nil, err } signature := stmt.Signature() return newPrepared(operator, signature), nil }