github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/plan/current_account.go (about) 1 // Copyright 2022 Matrix Origin 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package plan 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/common/moerr" 19 "github.com/matrixorigin/matrixone/pkg/container/types" 20 "github.com/matrixorigin/matrixone/pkg/pb/plan" 21 "github.com/matrixorigin/matrixone/pkg/sql/parsers/tree" 22 ) 23 24 func (builder *QueryBuilder) buildCurrentAccount(tbl *tree.TableFunction, ctx *BindContext, exprs []*plan.Expr, childId int32) (int32, error) { 25 if len(tbl.Func.Exprs) > 0 { 26 return 0, moerr.NewInvalidArg(builder.GetContext(), "current_account function has invalid input args length", len(tbl.Func.Exprs)) 27 } 28 node := &plan.Node{ 29 NodeType: plan.Node_FUNCTION_SCAN, 30 Stats: &plan.Stats{}, 31 TableDef: &plan.TableDef{ 32 TableType: "func_table", 33 TblFunc: &plan.TableFunction{ 34 Name: "current_account", 35 }, 36 Cols: []*plan.ColDef{ 37 { 38 Name: "account_name", 39 Typ: plan.Type{ 40 Id: int32(types.T_varchar), 41 Width: types.MaxVarcharLen, 42 }, 43 }, 44 { 45 Name: "account_id", 46 Typ: plan.Type{ 47 Id: int32(types.T_uint32), 48 Width: types.MaxVarcharLen, 49 }, 50 }, 51 { 52 Name: "user_name", 53 Typ: plan.Type{ 54 Id: int32(types.T_varchar), 55 Width: types.MaxVarcharLen, 56 }, 57 }, 58 { 59 Name: "user_id", 60 Typ: plan.Type{ 61 Id: int32(types.T_uint32), 62 Width: types.MaxVarcharLen, 63 }, 64 }, 65 { 66 Name: "role_name", 67 Typ: plan.Type{ 68 Id: int32(types.T_varchar), 69 Width: types.MaxVarcharLen, 70 }, 71 }, 72 { 73 Name: "role_id", 74 Typ: plan.Type{ 75 Id: int32(types.T_uint32), 76 Width: types.MaxVarcharLen, 77 }, 78 }, 79 }, 80 }, 81 BindingTags: []int32{builder.genNewTag()}, 82 Children: []int32{childId}, 83 TblFuncExprList: exprs, 84 } 85 return builder.appendNode(node, ctx), nil 86 }