Skip to content

Commit d530b90

Browse files
committed
move pkg/sql/plan to planner
1 parent 735ad6f commit d530b90

469 files changed

Lines changed: 3467 additions & 3566 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pkg/backup/tae.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import (
3939
"github.com/matrixorigin/matrixone/pkg/fileservice"
4040
"github.com/matrixorigin/matrixone/pkg/logutil"
4141
"github.com/matrixorigin/matrixone/pkg/objectio"
42-
"github.com/matrixorigin/matrixone/pkg/sql/plan/function/ctl"
42+
"github.com/matrixorigin/matrixone/pkg/sql/planner/function/ctl"
4343
"github.com/matrixorigin/matrixone/pkg/util/executor"
4444
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common"
4545
"github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/checkpoint"

pkg/cdc/sinker_v2.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/matrixorigin/matrixone/pkg/logutil"
2828
"github.com/matrixorigin/matrixone/pkg/objectio"
2929
"github.com/matrixorigin/matrixone/pkg/pb/plan"
30-
plan2 "github.com/matrixorigin/matrixone/pkg/sql/plan"
30+
"github.com/matrixorigin/matrixone/pkg/sql/planner"
3131
v2 "github.com/matrixorigin/matrixone/pkg/util/metric/v2"
3232
"go.uber.org/zap"
3333
)
@@ -190,7 +190,7 @@ var CreateMysqlSinker2 = func(
190190
return nil, moerr.NewInternalErrorNoCtx("external table is not supported")
191191
}
192192

193-
createSql, _, err = plan2.ConstructCreateTableSQL(nil, &newTableDef, nil, true, nil)
193+
createSql, _, err = planner.ConstructCreateTableSQL(nil, &newTableDef, nil, true, nil)
194194
if err != nil {
195195
executor.Close()
196196
return nil, err

pkg/cdc/sinker_v2_sql_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/matrixorigin/matrixone/pkg/common/moerr"
2323
"github.com/matrixorigin/matrixone/pkg/container/batch"
2424
"github.com/matrixorigin/matrixone/pkg/container/types"
25-
"github.com/matrixorigin/matrixone/pkg/sql/plan"
25+
"github.com/matrixorigin/matrixone/pkg/pb/plan"
2626
)
2727

2828
// CDCStatementBuilder constructs SQL statements for CDC sink operations.

pkg/cnservice/server_query.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
"github.com/matrixorigin/matrixone/pkg/perfcounter"
3838
"github.com/matrixorigin/matrixone/pkg/queryservice"
3939
qclient "github.com/matrixorigin/matrixone/pkg/queryservice/client"
40-
"github.com/matrixorigin/matrixone/pkg/sql/plan/function/ctl"
40+
"github.com/matrixorigin/matrixone/pkg/sql/planner/function/ctl"
4141
"github.com/matrixorigin/matrixone/pkg/txn/client"
4242
"github.com/matrixorigin/matrixone/pkg/util/fault"
4343
"github.com/matrixorigin/matrixone/pkg/vm/engine/disttae"

pkg/container/vector/functionTools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/matrixorigin/matrixone/pkg/container/bytejson"
2323
"github.com/matrixorigin/matrixone/pkg/container/nulls"
2424
"github.com/matrixorigin/matrixone/pkg/container/types"
25-
functionUtil "github.com/matrixorigin/matrixone/pkg/sql/plan/function/functionUtil"
25+
functionUtil "github.com/matrixorigin/matrixone/pkg/sql/planner/function/functionUtil"
2626
)
2727

2828
// FunctionParameterWrapper is generated from a vector.

pkg/frontend/authenticate.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ import (
3030
"sync/atomic"
3131
"time"
3232

33-
"github.com/tidwall/btree"
34-
"golang.org/x/sync/errgroup"
35-
3633
"github.com/matrixorigin/matrixone/pkg/catalog"
3734
"github.com/matrixorigin/matrixone/pkg/clusterservice"
3835
"github.com/matrixorigin/matrixone/pkg/common/moerr"
@@ -53,8 +50,8 @@ import (
5350
"github.com/matrixorigin/matrixone/pkg/sql/parsers/dialect"
5451
"github.com/matrixorigin/matrixone/pkg/sql/parsers/dialect/mysql"
5552
"github.com/matrixorigin/matrixone/pkg/sql/parsers/tree"
56-
plan2 "github.com/matrixorigin/matrixone/pkg/sql/plan"
57-
"github.com/matrixorigin/matrixone/pkg/sql/plan/function"
53+
"github.com/matrixorigin/matrixone/pkg/sql/planner"
54+
"github.com/matrixorigin/matrixone/pkg/sql/planner/function"
5855
"github.com/matrixorigin/matrixone/pkg/sql/util"
5956
"github.com/matrixorigin/matrixone/pkg/stage"
6057
"github.com/matrixorigin/matrixone/pkg/stage/stageutil"
@@ -65,6 +62,8 @@ import (
6562
"github.com/matrixorigin/matrixone/pkg/util/trace"
6663
"github.com/matrixorigin/matrixone/pkg/util/trace/impl/motrace"
6764
"github.com/matrixorigin/matrixone/pkg/util/trace/impl/motrace/statistic"
65+
"github.com/tidwall/btree"
66+
"golang.org/x/sync/errgroup"
6867
)
6968

7069
type TenantInfo struct {
@@ -4559,7 +4558,7 @@ func doDropFunction(ctx context.Context, ses *Session, df *tree.DropFunction, rm
45594558
if execResultArrayHasData(erArray) {
45604559
receivedArgsType := make([]string, len(df.Args))
45614560
for i, arg := range df.Args {
4562-
typ, err := plan2.GetFunctionArgTypeStrFromAst(arg)
4561+
typ, err := planner.GetFunctionArgTypeStrFromAst(arg)
45634562
if err != nil {
45644563
return err
45654564
}
@@ -6043,7 +6042,7 @@ func (pota privilegeTipsArray) String() string {
60436042
}
60446043

60456044
// extractPrivilegeTipsFromPlan extracts the privilege tips from the plan
6046-
func extractPrivilegeTipsFromPlan(p *plan2.Plan) privilegeTipsArray {
6045+
func extractPrivilegeTipsFromPlan(p *plan.Plan) privilegeTipsArray {
60476046
//NOTE: the pts may be nil when the plan does operate any table.
60486047
var pts privilegeTipsArray
60496048
appendPt := func(pt privilegeTips) {
@@ -7167,7 +7166,7 @@ func checkRoleWhetherDatabaseOwner(ctx context.Context, ses *Session, dbName str
71677166
func authenticateUserCanExecuteStatementWithObjectTypeDatabaseAndTable(ctx context.Context,
71687167
ses *Session,
71697168
stmt tree.Statement,
7170-
p *plan2.Plan) (bool, statistic.StatsArray, error) {
7169+
p *plan.Plan) (bool, statistic.StatsArray, error) {
71717170
var stats statistic.StatsArray
71727171
stats.Reset()
71737172

@@ -8718,7 +8717,7 @@ func InitFunction(ses *Session, execCtx *ExecCtx, tenant *TenantInfo, cf *tree.C
87188717

87198718
// format return type
87208719
fmtctx = tree.NewFmtCtx(dialect.MYSQL, tree.WithQuoteString(true))
8721-
retTypeStr, err = plan2.GetFunctionTypeStrFromAst(cf.ReturnType.Type)
8720+
retTypeStr, err = planner.GetFunctionTypeStrFromAst(cf.ReturnType.Type)
87228721
if err != nil {
87238722
return err
87248723
}
@@ -8730,7 +8729,7 @@ func InitFunction(ses *Session, execCtx *ExecCtx, tenant *TenantInfo, cf *tree.C
87308729
argList[i] = &function.Arg{}
87318730
argList[i].Name = cf.Args[i].GetName(fmtctx)
87328731
fmtctx.Reset()
8733-
typ, err := plan2.GetFunctionArgTypeStrFromAst(cf.Args[i])
8732+
typ, err := planner.GetFunctionArgTypeStrFromAst(cf.Args[i])
87348733
if err != nil {
87358734
return err
87368735
}
@@ -8924,14 +8923,14 @@ func InitProcedure(ctx context.Context, ses *Session, tenant *TenantInfo, cp *tr
89248923
}
89258924
initMoProcedure = fmt.Sprintf(updateMoStoredProcedureFormat,
89268925
string(argsJson),
8927-
cp.Lang, plan2.EscapeFormat(cp.Body), dbName,
8926+
cp.Lang, planner.EscapeFormat(cp.Body), dbName,
89288927
tenant.GetUser(), types.CurrentTimestamp().String2(time.UTC, 0), "PROCEDURE", "DEFINER", "", "utf8mb4", "utf8mb4_0900_ai_ci", "utf8mb4_0900_ai_ci",
89298928
int32(id))
89308929
} else {
89318930
initMoProcedure = fmt.Sprintf(initMoStoredProcedureFormat,
89328931
string(cp.Name.Name.ObjectName),
89338932
string(argsJson),
8934-
cp.Lang, plan2.EscapeFormat(cp.Body), dbName,
8933+
cp.Lang, planner.EscapeFormat(cp.Body), dbName,
89358934
tenant.GetUser(), types.CurrentTimestamp().String2(time.UTC, 0), types.CurrentTimestamp().String2(time.UTC, 0), "PROCEDURE", "DEFINER", "", "utf8mb4", "utf8mb4_0900_ai_ci", "utf8mb4_0900_ai_ci")
89368935
}
89378936
err = bh.Exec(ctx, initMoProcedure)

pkg/frontend/authenticate2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
"github.com/matrixorigin/matrixone/pkg/catalog"
2121
"github.com/matrixorigin/matrixone/pkg/pb/plan"
22-
plan2 "github.com/matrixorigin/matrixone/pkg/sql/plan"
22+
"github.com/matrixorigin/matrixone/pkg/sql/planner"
2323
)
2424

2525
// verifyAccountCanOperateClusterTable determines the account can operate
@@ -229,7 +229,7 @@ var privilegeCacheIsEnabled = func(ctx context.Context, ses *Session) (bool, err
229229
}
230230

231231
// hasMoCtrl checks whether the plan has mo_ctrl
232-
func hasMoCtrl(p *plan2.Plan) bool {
232+
func hasMoCtrl(p *plan.Plan) bool {
233233
if p != nil && p.GetQuery() != nil { //select,insert select, update, delete
234234
q := p.GetQuery()
235235
if q.StmtType == plan.Query_INSERT || q.StmtType == plan.Query_SELECT {
@@ -239,7 +239,7 @@ func hasMoCtrl(p *plan2.Plan) bool {
239239
// select mo_ctrl ...
240240
// insert into ... select mo_ctrl ...
241241
for _, proj := range node.ProjectList {
242-
if plan2.HasMoCtrl(proj) {
242+
if planner.HasMoCtrl(proj) {
243243
return true
244244
}
245245
}
@@ -253,7 +253,7 @@ func hasMoCtrl(p *plan2.Plan) bool {
253253
// isTargetSysWhiteList checks if ALL DML target tables are in the whitelist.
254254
// Returns true only when all target tables are in the whitelist.
255255
// Returns false if any target table is not in the whitelist, or if there are no DML target tables.
256-
func isTargetSysWhiteList(p *plan2.Plan) bool {
256+
func isTargetSysWhiteList(p *plan.Plan) bool {
257257
if p == nil || p.GetQuery() == nil {
258258
return false
259259
}

pkg/frontend/authenticate2_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"github.com/stretchr/testify/assert"
2323

2424
"github.com/matrixorigin/matrixone/pkg/catalog"
25+
"github.com/matrixorigin/matrixone/pkg/pb/plan"
2526
plan3 "github.com/matrixorigin/matrixone/pkg/pb/plan"
26-
plan2 "github.com/matrixorigin/matrixone/pkg/sql/plan"
2727
)
2828

2929
func Test_verifyAccountCanOperateClusterTable(t *testing.T) {
@@ -199,12 +199,12 @@ func Test_hasMoCtrl(t *testing.T) {
199199
ret = hasMoCtrl(nil)
200200
assert.False(t, ret)
201201

202-
ret = hasMoCtrl(&plan2.Plan{})
202+
ret = hasMoCtrl(&plan.Plan{})
203203
assert.False(t, ret)
204204

205-
ret = hasMoCtrl(&plan2.Plan{
206-
Plan: &plan2.Plan_Query{
207-
Query: &plan2.Query{
205+
ret = hasMoCtrl(&plan.Plan{
206+
Plan: &plan.Plan_Query{
207+
Query: &plan.Query{
208208
StmtType: plan3.Query_SELECT,
209209
Nodes: []*plan3.Node{
210210
{

pkg/frontend/authenticate_test.go

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ import (
4848
"github.com/matrixorigin/matrixone/pkg/pb/txn"
4949
"github.com/matrixorigin/matrixone/pkg/queryservice"
5050
"github.com/matrixorigin/matrixone/pkg/sql/parsers/tree"
51-
plan2 "github.com/matrixorigin/matrixone/pkg/sql/plan"
5251
"github.com/matrixorigin/matrixone/pkg/stage"
5352
"github.com/matrixorigin/matrixone/pkg/testutil"
5453
"github.com/matrixorigin/matrixone/pkg/util/trace/impl/motrace/statistic"
@@ -3430,31 +3429,31 @@ func Test_determineDropTable(t *testing.T) {
34303429
func Test_determineDML(t *testing.T) {
34313430
type arg struct {
34323431
stmt tree.Statement
3433-
p *plan2.Plan
3432+
p *plan.Plan
34343433
}
34353434

34363435
args := []arg{
34373436
{
34383437
stmt: &tree.Select{},
3439-
p: &plan2.Plan{
3440-
Plan: &plan2.Plan_Query{
3441-
Query: &plan2.Query{
3442-
Nodes: []*plan2.Node{
3443-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "t", ObjName: "a"}},
3444-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "s", ObjName: "b"}},
3438+
p: &plan.Plan{
3439+
Plan: &plan.Plan_Query{
3440+
Query: &plan.Query{
3441+
Nodes: []*plan.Node{
3442+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "t", ObjName: "a"}},
3443+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "s", ObjName: "b"}},
34453444
},
34463445
},
34473446
},
34483447
},
34493448
},
34503449
{
34513450
stmt: &tree.Update{},
3452-
p: &plan2.Plan{
3453-
Plan: &plan2.Plan_Query{
3454-
Query: &plan2.Query{
3455-
Nodes: []*plan2.Node{
3456-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "t", ObjName: "a"}},
3457-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "s", ObjName: "b"}},
3451+
p: &plan.Plan{
3452+
Plan: &plan.Plan_Query{
3453+
Query: &plan.Query{
3454+
Nodes: []*plan.Node{
3455+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "t", ObjName: "a"}},
3456+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "s", ObjName: "b"}},
34583457
{NodeType: plan.Node_INSERT},
34593458
},
34603459
},
@@ -3463,12 +3462,12 @@ func Test_determineDML(t *testing.T) {
34633462
},
34643463
{
34653464
stmt: &tree.Delete{},
3466-
p: &plan2.Plan{
3467-
Plan: &plan2.Plan_Query{
3468-
Query: &plan2.Query{
3469-
Nodes: []*plan2.Node{
3470-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "t", ObjName: "a"}},
3471-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "s", ObjName: "b"}},
3465+
p: &plan.Plan{
3466+
Plan: &plan.Plan_Query{
3467+
Query: &plan.Query{
3468+
Nodes: []*plan.Node{
3469+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "t", ObjName: "a"}},
3470+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "s", ObjName: "b"}},
34723471
{NodeType: plan.Node_DELETE},
34733472
},
34743473
},
@@ -3477,13 +3476,13 @@ func Test_determineDML(t *testing.T) {
34773476
},
34783477
{ //insert into select
34793478
stmt: &tree.Insert{},
3480-
p: &plan2.Plan{
3481-
Plan: &plan2.Plan_Query{
3482-
Query: &plan2.Query{
3483-
Nodes: []*plan2.Node{
3484-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "t", ObjName: "a"}},
3485-
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan2.ObjectRef{SchemaName: "s", ObjName: "b"}},
3486-
{NodeType: plan.Node_INSERT, ObjRef: &plan2.ObjectRef{SchemaName: "s", ObjName: "b"}},
3479+
p: &plan.Plan{
3480+
Plan: &plan.Plan_Query{
3481+
Query: &plan.Query{
3482+
Nodes: []*plan.Node{
3483+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "t", ObjName: "a"}},
3484+
{NodeType: plan.Node_TABLE_SCAN, ObjRef: &plan.ObjectRef{SchemaName: "s", ObjName: "b"}},
3485+
{NodeType: plan.Node_INSERT, ObjRef: &plan.ObjectRef{SchemaName: "s", ObjName: "b"}},
34873486
},
34883487
},
34893488
},

pkg/frontend/back_exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
"github.com/matrixorigin/matrixone/pkg/sql/parsers"
3838
"github.com/matrixorigin/matrixone/pkg/sql/parsers/dialect/mysql"
3939
"github.com/matrixorigin/matrixone/pkg/sql/parsers/tree"
40-
plan2 "github.com/matrixorigin/matrixone/pkg/sql/plan"
40+
"github.com/matrixorigin/matrixone/pkg/sql/planner"
4141
"github.com/matrixorigin/matrixone/pkg/util"
4242
"github.com/matrixorigin/matrixone/pkg/util/trace"
4343
"github.com/matrixorigin/matrixone/pkg/util/trace/impl/motrace"
@@ -1101,7 +1101,7 @@ func (backSes *backSession) GetStorage() engine.Engine {
11011101
return getPu(backSes.GetService()).StorageEngine
11021102
}
11031103

1104-
func (backSes *backSession) GetStatsCache() *plan2.StatsCache {
1104+
func (backSes *backSession) GetStatsCache() *planner.StatsCache {
11051105
return nil
11061106
}
11071107

0 commit comments

Comments
 (0)