featurebase/sql3/planner/optop.go
pokeeffe-molecula e24978c4a7 And now....INNER JOIN! (#2230)
* ID sql3 internal type representation is int64; fixed a bug that assumed incorrectly that it wasn't

* refactored some names for clarity

* primary: get nested loop joins to work; secondary get  brute force aggregations for SUM working

* added tests; removed debug output

* review feedback

* Update sql3/planner/compileselect.go

review feedback

Co-authored-by: Travis Turner <travis@pilosa.com>

Co-authored-by: Travis Turner <travis@pilosa.com>
2022-09-30 11:25:27 -07:00

72 lines
1.6 KiB
Go

// Copyright 2022 Molecula Corp. All rights reserved.
package planner
import (
"context"
"fmt"
"github.com/featurebasedb/featurebase/v3/sql3/planner/types"
)
// PlanOpTop implements the TOP operator
type PlanOpTop struct {
ChildOp types.PlanOperator
expr types.PlanExpression
warnings []string
}
func NewPlanOpTop(expr types.PlanExpression, child types.PlanOperator) *PlanOpTop {
return &PlanOpTop{
ChildOp: child,
expr: expr,
warnings: make([]string, 0),
}
}
func (p *PlanOpTop) Schema() types.Schema {
return p.ChildOp.Schema()
}
func (p *PlanOpTop) Iterator(ctx context.Context, row types.Row) (types.RowIterator, error) {
return p.ChildOp.Iterator(ctx, row)
}
func (p *PlanOpTop) Children() []types.PlanOperator {
return []types.PlanOperator{
p.ChildOp,
}
}
func (p *PlanOpTop) WithChildren(children ...types.PlanOperator) (types.PlanOperator, error) {
return nil, nil
}
func (p *PlanOpTop) Plan() map[string]interface{} {
result := make(map[string]interface{})
result["_op"] = fmt.Sprintf("%T", p)
sc := make([]string, 0)
for _, e := range p.Schema() {
sc = append(sc, fmt.Sprintf("'%s', '%s', '%s'", e.ColumnName, e.RelationName, e.Type.TypeName()))
}
result["_schema"] = sc
result["expr"] = p.expr
result["child"] = p.ChildOp.Plan()
return result
}
func (p *PlanOpTop) String() string {
return ""
}
func (p *PlanOpTop) AddWarning(warning string) {
p.warnings = append(p.warnings, warning)
}
func (p *PlanOpTop) Warnings() []string {
var w []string
w = append(w, p.warnings...)
w = append(w, p.ChildOp.Warnings()...)
return w
}