github.com/matrixorigin/matrixone@v1.2.0/pkg/sql/plan/function/ctl/cmd_merge_test.go (about) 1 // Copyright 2024 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 ctl 16 17 import ( 18 "github.com/matrixorigin/matrixone/pkg/objectio" 19 "github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common" 20 "github.com/stretchr/testify/require" 21 "testing" 22 ) 23 24 func TestParseArgs(t *testing.T) { 25 cases := []struct { 26 s string 27 r arguments 28 e bool 29 }{ 30 { 31 s: "db1.table1", 32 r: arguments{db: "db1", tbl: "table1", targetObjSize: defaultTargetObjectSize}, 33 }, 34 { 35 s: "db1.table1:all:small", 36 r: arguments{db: "db1", tbl: "table1", filter: "small", targetObjSize: defaultTargetObjectSize}, 37 }, 38 { 39 s: "db1.table1:all:small:1M", 40 r: arguments{db: "db1", tbl: "table1", filter: "small", targetObjSize: common.Const1MBytes}, 41 }, 42 { 43 s: "db1", 44 e: true, 45 }, 46 { 47 s: "db1.table1:018f27b6-c6e1-7bef-a1e8-0f639ddedeef_0,018f27b6-c6e1-7bef-a1e8-0f639ddede00_0", 48 r: arguments{db: "db1", tbl: "table1", objs: []objectio.ObjectStats{ 49 { 50 0x01, 0x8f, 0x27, 0xb6, 0xc6, 0xe1, 0x7b, 0xef, 51 0xa1, 0xe8, 0x0f, 0x63, 0x9d, 0xde, 0xde, 0xef, 52 0x00, 0x00, 0x30, 0x31, 0x38, 0x66, 0x32, 0x37, 53 0x62, 0x36, 0x2d, 0x63, 0x36, 0x65, 0x31, 0x2d, 54 0x37, 0x62, 0x65, 0x66, 0x2d, 0x61, 0x31, 0x65, 55 0x38, 0x2d, 0x30, 0x66, 0x36, 0x33, 0x39, 0x64, 56 0x64, 0x65, 0x64, 0x65, 0x65, 0x66, 0x5f, 0x30, 57 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 69 }, 70 { 71 0x01, 0x8f, 0x27, 0xb6, 0xc6, 0xe1, 0x7b, 0xef, 72 0xa1, 0xe8, 0x0f, 0x63, 0x9d, 0xde, 0xde, 0x00, 73 0x00, 0x00, 0x30, 0x31, 0x38, 0x66, 0x32, 0x37, 74 0x62, 0x36, 0x2d, 0x63, 0x36, 0x65, 0x31, 0x2d, 75 0x37, 0x62, 0x65, 0x66, 0x2d, 0x61, 0x31, 0x65, 76 0x38, 0x2d, 0x30, 0x66, 0x36, 0x33, 0x39, 0x64, 77 0x64, 0x65, 0x64, 0x65, 0x30, 0x30, 0x5f, 0x30, 78 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 81 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 82 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 85 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 89 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 90 }, 91 }, targetObjSize: defaultTargetObjectSize}, 92 }, 93 { 94 s: "db1.table1:018f27b6-c6e1-7bef-a1e8-0f639ddedeef_0,018f27b6-c6e1-7bef-a1e8-0f639ddede00_0:1M", 95 r: arguments{db: "db1", tbl: "table1", objs: []objectio.ObjectStats{ 96 { 97 0x01, 0x8f, 0x27, 0xb6, 0xc6, 0xe1, 0x7b, 0xef, 98 0xa1, 0xe8, 0x0f, 0x63, 0x9d, 0xde, 0xde, 0xef, 99 0x00, 0x00, 0x30, 0x31, 0x38, 0x66, 0x32, 0x37, 100 0x62, 0x36, 0x2d, 0x63, 0x36, 0x65, 0x31, 0x2d, 101 0x37, 0x62, 0x65, 0x66, 0x2d, 0x61, 0x31, 0x65, 102 0x38, 0x2d, 0x30, 0x66, 0x36, 0x33, 0x39, 0x64, 103 0x64, 0x65, 0x64, 0x65, 0x65, 0x66, 0x5f, 0x30, 104 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 115 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 116 }, 117 { 118 0x01, 0x8f, 0x27, 0xb6, 0xc6, 0xe1, 0x7b, 0xef, 119 0xa1, 0xe8, 0x0f, 0x63, 0x9d, 0xde, 0xde, 0x00, 120 0x00, 0x00, 0x30, 0x31, 0x38, 0x66, 0x32, 0x37, 121 0x62, 0x36, 0x2d, 0x63, 0x36, 0x65, 0x31, 0x2d, 122 0x37, 0x62, 0x65, 0x66, 0x2d, 0x61, 0x31, 0x65, 123 0x38, 0x2d, 0x30, 0x66, 0x36, 0x33, 0x39, 0x64, 124 0x64, 0x65, 0x64, 0x65, 0x30, 0x30, 0x5f, 0x30, 125 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 129 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 130 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 137 }, 138 }, targetObjSize: common.Const1MBytes}, 139 }, 140 { 141 s: "db1.table1:018f27b6-c6e1-7bef-a1e8-0f639ddedeef_0,018f27b6-c6e1-7bef-a1e8-0f639ddede00_0:small:1M", 142 e: true, 143 }, 144 } 145 146 for _, c := range cases { 147 a, e := parseArgs(c.s) 148 if c.e { 149 require.Error(t, e) 150 } else { 151 require.Equal(t, c.r, a) 152 } 153 } 154 }