This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
/
opsubquery.go
74 lines (60 loc) · 1.65 KB
/
opsubquery.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright 2022 Molecula Corp. All rights reserved.
package planner
import (
"context"
"fmt"
"github.com/featurebasedb/featurebase/v3/sql3"
"github.com/featurebasedb/featurebase/v3/sql3/planner/types"
)
// PlanOpSubquery is an operator for a subquery
type PlanOpSubquery struct {
ChildOp types.PlanOperator
warnings []string
}
func NewPlanOpSubquery(child types.PlanOperator) *PlanOpSubquery {
return &PlanOpSubquery{
ChildOp: child,
warnings: make([]string, 0),
}
}
func (p *PlanOpSubquery) Schema() types.Schema {
return p.ChildOp.Schema()
}
func (p *PlanOpSubquery) Iterator(ctx context.Context, row types.Row) (types.RowIterator, error) {
return p.ChildOp.Iterator(ctx, row)
}
func (p *PlanOpSubquery) Children() []types.PlanOperator {
return []types.PlanOperator{
p.ChildOp,
}
}
func (p *PlanOpSubquery) WithChildren(children ...types.PlanOperator) (types.PlanOperator, error) {
if len(children) != 1 {
return nil, sql3.NewErrInternalf("unexpected number of children '%d'", len(children))
}
return NewPlanOpSubquery(children[0]), nil
}
func (p *PlanOpSubquery) Plan() map[string]interface{} {
result := make(map[string]interface{})
result["_op"] = fmt.Sprintf("%T", p)
result["_schema"] = p.Schema().Plan()
result["child"] = p.ChildOp.Plan()
return result
}
func (p *PlanOpSubquery) String() string {
return ""
}
func (p *PlanOpSubquery) AddWarning(warning string) {
p.warnings = append(p.warnings, warning)
}
func (p *PlanOpSubquery) Warnings() []string {
var w []string
w = append(w, p.warnings...)
if p.ChildOp != nil {
w = append(w, p.ChildOp.Warnings()...)
}
return w
}
func (p *PlanOpSubquery) Name() string {
return ""
}