This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 230
/
planexpression.go
59 lines (44 loc) · 1.54 KB
/
planexpression.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
package types
import (
"context"
"fmt"
"github.com/featurebasedb/featurebase/v3/sql3/parser"
)
// PlanExpression is an expression node for an execution plan
type PlanExpression interface {
fmt.Stringer
// evaluates expression based on current row
Evaluate(currentRow []interface{}) (interface{}, error)
// returns the type of the expression
Type() parser.ExprDataType
// returns the child expressions for this expression
Children() []PlanExpression
// creates a new expression node with the children replaced
WithChildren(children ...PlanExpression) (PlanExpression, error)
// returns a map containing a rich description of this expression; intended to be
// marshalled into json
Plan() map[string]interface{}
}
// AggregationBuffer is an interface to something that maintains an aggregate
// during query execution.
type AggregationBuffer interface {
Eval(ctx context.Context) (interface{}, error)
Update(ctx context.Context, row Row) error
}
// Aggregable is an interface for an expression that is a an aggregate.
type Aggregable interface {
fmt.Stringer
// creates a new aggregation buffer for this aggregate
NewBuffer() (AggregationBuffer, error)
// convenience to get the first argument of the aggregate
FirstChildExpr() PlanExpression
// returns all the child expressions for this aggregate
Children() []PlanExpression
// returns the type of the aggregate
Type() parser.ExprDataType
}
// IdentifiableByName is an interface for something that can be identified by a
// name.
type IdentifiableByName interface {
Name() string
}