-
Notifications
You must be signed in to change notification settings - Fork 218
Expand file tree
/
Copy pathdistinct_plan.go
More file actions
74 lines (61 loc) · 1.31 KB
/
distinct_plan.go
File metadata and controls
74 lines (61 loc) · 1.31 KB
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
/*
* Radon
*
* Copyright 2018 The Radon Authors.
* Code is licensed under the GPLv3.
*
*/
package planner
import (
"github.com/pkg/errors"
"github.com/xelabs/go-mysqlstack/sqlparser"
"github.com/xelabs/go-mysqlstack/xlog"
)
var (
_ Plan = &DistinctPlan{}
)
// DistinctPlan represents distinct plan.
type DistinctPlan struct {
log *xlog.Log
node *sqlparser.Select
// type
Typ PlanType
}
// NewDistinctPlan used to create DistinctPlan.
func NewDistinctPlan(log *xlog.Log, node *sqlparser.Select) *DistinctPlan {
return &DistinctPlan{
log: log,
node: node,
Typ: PlanTypeDistinct,
}
}
// analyze used to check the distinct is at the support level.
// Unsupported:
// 1. all distinct clause.
func (p *DistinctPlan) analyze() error {
node := p.node
if node.Distinct != "" {
return errors.New("unsupported: distinct")
}
return nil
}
// Build used to build distributed querys.
func (p *DistinctPlan) Build() error {
return p.analyze()
}
// Type returns the type of the plan.
func (p *DistinctPlan) Type() PlanType {
return p.Typ
}
// JSON returns the plan info.
func (p *DistinctPlan) JSON() string {
return ""
}
// Children returns the children of the plan.
func (p *DistinctPlan) Children() *PlanTree {
return nil
}
// Size returns the memory size.
func (p *DistinctPlan) Size() int {
return 0
}