This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
/
opnulltable.go
69 lines (54 loc) · 1.52 KB
/
opnulltable.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
// Copyright 2022 Molecula Corp. All rights reserved.
package planner
import (
"context"
"fmt"
"github.com/featurebasedb/featurebase/v3/sql3/planner/types"
)
// PlanOpNullTable is an operator for a null table
// basically when you do select 1, you're using the null table
type PlanOpNullTable struct {
warnings []string
}
func NewPlanOpNullTable() *PlanOpNullTable {
return &PlanOpNullTable{
warnings: make([]string, 0),
}
}
func (p *PlanOpNullTable) Schema() types.Schema {
return types.Schema{}
}
func (p *PlanOpNullTable) Iterator(ctx context.Context, row types.Row) (types.RowIterator, error) {
return &nullTableIterator{}, nil
}
func (p *PlanOpNullTable) WithChildren(children ...types.PlanOperator) (types.PlanOperator, error) {
return NewPlanOpNullTable(), nil
}
func (p *PlanOpNullTable) Children() []types.PlanOperator {
return []types.PlanOperator{}
}
func (p *PlanOpNullTable) Plan() map[string]interface{} {
result := make(map[string]interface{})
result["_op"] = fmt.Sprintf("%T", p)
result["_schema"] = p.Schema().Plan()
return result
}
func (p *PlanOpNullTable) String() string {
return ""
}
func (p *PlanOpNullTable) AddWarning(warning string) {
p.warnings = append(p.warnings, warning)
}
func (p *PlanOpNullTable) Warnings() []string {
return p.warnings
}
type nullTableIterator struct {
rowConsumed bool
}
func (i *nullTableIterator) Next(ctx context.Context) (types.Row, error) {
if !i.rowConsumed {
i.rowConsumed = true
return make([]interface{}, 0), nil
}
return nil, types.ErrNoMoreRows
}