@@ -52,18 +52,18 @@ public class TruncateTableCommandTest extends TestWithFeService {
52
52
@ Override
53
53
protected void runBeforeAll () throws Exception {
54
54
Config .enable_debug_points = true ;
55
- createDatabase ("test " );
56
- connectContext .setDatabase ("test " );
55
+ createDatabase ("testcommand " );
56
+ connectContext .setDatabase ("testcommand " );
57
57
58
- String createTableStr = "create table test.tbl (d1 date, k1 int, k2 bigint)"
58
+ String createTableStr = "create table testcommand.tblcommand (d1 date, k1 int, k2 bigint)"
59
59
+ "duplicate key(d1, k1) "
60
60
+ "PARTITION BY RANGE(d1)"
61
61
+ "(PARTITION p20210901 VALUES [('2021-09-01'), ('2021-09-02')))"
62
62
+ "distributed by hash(k1) buckets 2 "
63
63
+ "properties('replication_num' = '1');" ;
64
64
createTable (createTableStr );
65
65
66
- String createTable2 = "CREATE TABLE test.case_sensitive_table (\n "
66
+ String createTable2 = "CREATE TABLE testcommand.case_sensitive_table_command (\n "
67
67
+ " `date_id` date NULL COMMENT \" \" ,\n "
68
68
+ " `column2` tinyint(4) NULL COMMENT \" \" \n "
69
69
+ ") ENGINE=OLAP\n "
@@ -93,7 +93,7 @@ public void testValidate(@Mocked Env env, @Mocked AccessControllerManager access
93
93
}
94
94
};
95
95
96
- String truncateStr = "TRUNCATE TABLE internal.test.case_sensitive_table PARTITION P20211008; \n " ;
96
+ String truncateStr = "TRUNCATE TABLE internal.testcommand.case_sensitive_table_command PARTITION P20211008; \n " ;
97
97
98
98
NereidsParser nereidsParser = new NereidsParser ();
99
99
LogicalPlan plan = nereidsParser .parseSingle (truncateStr );
@@ -108,12 +108,12 @@ public void testValidate(@Mocked Env env, @Mocked AccessControllerManager access
108
108
connectContext .setDatabase ("test" ); //reset database
109
109
110
110
// test no table
111
- tableNameInfo = new TableNameInfo ("internal" , "test " , "" );
111
+ tableNameInfo = new TableNameInfo ("internal" , "testcommand " , "" );
112
112
TruncateTableCommand truncateTableCommand1 = new TruncateTableCommand (tableNameInfo , Optional .empty (), false );
113
113
Assertions .assertThrows (AnalysisException .class , () -> truncateTableCommand1 .validate (connectContext ));
114
114
115
115
// test no partition
116
- tableNameInfo = new TableNameInfo ("internal" , "test " , "test" );
116
+ tableNameInfo = new TableNameInfo ("internal" , "testcommand " , "test" );
117
117
PartitionNamesInfo partitionNamesInfo = new PartitionNamesInfo (false );
118
118
TruncateTableCommand truncateTableCommand2 = new TruncateTableCommand (tableNameInfo , Optional .of (partitionNamesInfo ), false );
119
119
Assertions .assertThrows (AnalysisException .class , () -> truncateTableCommand2 .validate (connectContext ));
@@ -122,8 +122,8 @@ public void testValidate(@Mocked Env env, @Mocked AccessControllerManager access
122
122
@ Test
123
123
public void testTruncateWithCaseInsensitivePartitionName () throws Exception {
124
124
//now in order to support auto create partition, need set partition name is case sensitive
125
- Database db = Env .getCurrentInternalCatalog ().getDbNullable ("test " );
126
- OlapTable tbl = db .getOlapTableOrDdlException ("case_sensitive_table " );
125
+ Database db = Env .getCurrentInternalCatalog ().getDbNullable ("testcommand " );
126
+ OlapTable tbl = db .getOlapTableOrDdlException ("case_sensitive_table_command " );
127
127
128
128
long p20211006Id = tbl .getPartition ("p20211006" ).getId ();
129
129
long p20211007Id = tbl .getPartition ("P20211007" ).getId ();
@@ -133,7 +133,7 @@ public void testTruncateWithCaseInsensitivePartitionName() throws Exception {
133
133
Partition p20211008 = tbl .getPartition ("P20211008" );
134
134
p20211008 .updateVisibleVersion (2L );
135
135
p20211008 .setNextVersion (p20211008 .getVisibleVersion () + 1 );
136
- String truncateStr = "TRUNCATE TABLE internal.test.case_sensitive_table PARTITION P20211008; \n " ;
136
+ String truncateStr = "TRUNCATE TABLE internal.testcommand.case_sensitive_table_command PARTITION P20211008; \n " ;
137
137
138
138
NereidsParser nereidsParser = new NereidsParser ();
139
139
LogicalPlan plan = nereidsParser .parseSingle (truncateStr );
@@ -142,7 +142,7 @@ public void testTruncateWithCaseInsensitivePartitionName() throws Exception {
142
142
Assertions .assertNotEquals (p20211008Id , tbl .getPartition ("P20211008" ).getId ());
143
143
144
144
// 2. truncate P20211007
145
- truncateStr = "TRUNCATE TABLE internal.test.case_sensitive_table PARTITION P20211007 force; \n " ;
145
+ truncateStr = "TRUNCATE TABLE internal.testcommand.case_sensitive_table_command PARTITION P20211007 force; \n " ;
146
146
plan = nereidsParser .parseSingle (truncateStr );
147
147
Assertions .assertTrue (plan instanceof TruncateTableCommand );
148
148
Env .getCurrentEnv ().truncateTable ((TruncateTableCommand ) plan );
@@ -156,77 +156,77 @@ public void testTruncateWithCaseInsensitivePartitionName() throws Exception {
156
156
157
157
@ Test
158
158
public void testTruncateTable () throws Exception {
159
- String stmtStr = "ALTER TABLE internal.test.tbl ADD PARTITION p20210902 VALUES [('2021-09-02'), ('2021-09-03'))"
159
+ String stmtStr = "ALTER TABLE internal.testcommand.tblcommand ADD PARTITION p20210902 VALUES [('2021-09-02'), ('2021-09-03'))"
160
160
+ " DISTRIBUTED BY HASH(`k1`) BUCKETS 3;" ;
161
161
alterTable (stmtStr );
162
- stmtStr = "ALTER TABLE internal.test.tbl ADD PARTITION p20210903 VALUES [('2021-09-03'), ('2021-09-04'))"
162
+ stmtStr = "ALTER TABLE internal.testcommand.tblcommand ADD PARTITION p20210903 VALUES [('2021-09-03'), ('2021-09-04'))"
163
163
+ " DISTRIBUTED BY HASH(`k1`) BUCKETS 4;" ;
164
164
alterTable (stmtStr );
165
- stmtStr = "ALTER TABLE internal.test.tbl ADD PARTITION p20210904 VALUES [('2021-09-04'), ('2021-09-05'))"
165
+ stmtStr = "ALTER TABLE internal.testcommand.tblcommand ADD PARTITION p20210904 VALUES [('2021-09-04'), ('2021-09-05'))"
166
166
+ " DISTRIBUTED BY HASH(`k1`) BUCKETS 5;" ;
167
167
alterTable (stmtStr );
168
- checkShowTabletResultNum ("internal.test.tbl " , "p20210901" , 2 );
169
- checkShowTabletResultNum ("internal.test.tbl " , "p20210902" , 3 );
170
- checkShowTabletResultNum ("internal.test.tbl " , "p20210903" , 4 );
171
- checkShowTabletResultNum ("internal.test.tbl " , "p20210904" , 5 );
168
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210901" , 2 );
169
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210902" , 3 );
170
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210903" , 4 );
171
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210904" , 5 );
172
172
173
- String truncateStr = "truncate table internal.test.tbl ;" ;
173
+ String truncateStr = "truncate table internal.testcommand.tblcommand ;" ;
174
174
NereidsParser nereidsParser = new NereidsParser ();
175
175
LogicalPlan plan = nereidsParser .parseSingle (truncateStr );
176
176
Assertions .assertTrue (plan instanceof TruncateTableCommand );
177
177
Env .getCurrentEnv ().truncateTable ((TruncateTableCommand ) plan );
178
178
179
- checkShowTabletResultNum ("internal.test.tbl " , "p20210901" , 2 );
180
- checkShowTabletResultNum ("internal.test.tbl " , "p20210902" , 3 );
181
- checkShowTabletResultNum ("internal.test.tbl " , "p20210903" , 4 );
182
- checkShowTabletResultNum ("internal.test.tbl " , "p20210904" , 5 );
179
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210901" , 2 );
180
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210902" , 3 );
181
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210903" , 4 );
182
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210904" , 5 );
183
183
184
- truncateStr = "truncate table internal.test.tbl partition(p20210901, p20210902, p20210903, p20210904);" ;
184
+ truncateStr = "truncate table internal.testcommand.tblcommand partition(p20210901, p20210902, p20210903, p20210904);" ;
185
185
plan = nereidsParser .parseSingle (truncateStr );
186
186
Assertions .assertTrue (plan instanceof TruncateTableCommand );
187
187
Env .getCurrentEnv ().truncateTable ((TruncateTableCommand ) plan );
188
188
189
- checkShowTabletResultNum ("internal.test.tbl " , "p20210901" , 2 );
190
- checkShowTabletResultNum ("internal.test.tbl " , "p20210902" , 3 );
191
- checkShowTabletResultNum ("internal.test.tbl " , "p20210903" , 4 );
192
- checkShowTabletResultNum ("internal.test.tbl " , "p20210904" , 5 );
189
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210901" , 2 );
190
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210902" , 3 );
191
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210903" , 4 );
192
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210904" , 5 );
193
193
194
- truncateStr = "truncate table internal.test.tbl partition (p20210901);" ;
194
+ truncateStr = "truncate table internal.testcommand.tblcommand partition (p20210901);" ;
195
195
plan = nereidsParser .parseSingle (truncateStr );
196
196
Assertions .assertTrue (plan instanceof TruncateTableCommand );
197
197
Env .getCurrentEnv ().truncateTable ((TruncateTableCommand ) plan );
198
- checkShowTabletResultNum ("internal.test.tbl " , "p20210901" , 2 );
198
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210901" , 2 );
199
199
200
- truncateStr = "truncate table internal.test.tbl partition (p20210902);" ;
200
+ truncateStr = "truncate table internal.testcommand.tblcommand partition (p20210902);" ;
201
201
plan = nereidsParser .parseSingle (truncateStr );
202
202
Assertions .assertTrue (plan instanceof TruncateTableCommand );
203
203
Env .getCurrentEnv ().truncateTable ((TruncateTableCommand ) plan );
204
- checkShowTabletResultNum ("internal.test.tbl " , "p20210902" , 3 );
204
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210902" , 3 );
205
205
206
- truncateStr = "truncate table internal.test.tbl partition (p20210903);" ;
206
+ truncateStr = "truncate table internal.testcommand.tblcommand partition (p20210903);" ;
207
207
plan = nereidsParser .parseSingle (truncateStr );
208
208
Assertions .assertTrue (plan instanceof TruncateTableCommand );
209
209
Env .getCurrentEnv ().truncateTable ((TruncateTableCommand ) plan );
210
- checkShowTabletResultNum ("internal.test.tbl " , "p20210903" , 4 );
210
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210903" , 4 );
211
211
212
- truncateStr = "truncate table internal.test.tbl partition (p20210904);" ;
212
+ truncateStr = "truncate table internal.testcommand.tblcommand partition (p20210904);" ;
213
213
plan = nereidsParser .parseSingle (truncateStr );
214
214
Assertions .assertTrue (plan instanceof TruncateTableCommand );
215
215
Env .getCurrentEnv ().truncateTable ((TruncateTableCommand ) plan );
216
- checkShowTabletResultNum ("internal.test.tbl " , "p20210904" , 5 );
216
+ checkShowTabletResultNum ("internal.testcommand.tblcommand " , "p20210904" , 5 );
217
217
}
218
218
219
219
@ Test
220
220
public void testTruncateTableFailed () throws Exception {
221
- String createTableStr = "create table internal.test .tbl2(d1 date, k1 int, k2 bigint)"
221
+ String createTableStr = "create table internal.testcommand .tbl2(d1 date, k1 int, k2 bigint)"
222
222
+ "duplicate key(d1, k1) "
223
223
+ "PARTITION BY RANGE(d1)"
224
224
+ "(PARTITION p20210901 VALUES [('2021-09-01'), ('2021-09-02')))"
225
225
+ "distributed by hash(k1) buckets 2 "
226
226
+ "properties('replication_num' = '1');" ;
227
227
createTable (createTableStr );
228
228
String partitionName = "p20210901" ;
229
- Database db = Env .getCurrentInternalCatalog ().getDbNullable ("test " );
229
+ Database db = Env .getCurrentInternalCatalog ().getDbNullable ("testcommand " );
230
230
OlapTable tbl2 = db .getOlapTableOrDdlException ("tbl2" );
231
231
Assertions .assertNotNull (tbl2 );
232
232
@@ -245,7 +245,7 @@ public void testTruncateTableFailed() throws Exception {
245
245
}
246
246
247
247
DebugPointUtil .addDebugPoint ("InternalCatalog.truncateTable.metaChanged" , new DebugPointUtil .DebugPoint ());
248
- String truncateStr = "truncate table internal.test .tbl2 partition (" + partitionName + ");" ;
248
+ String truncateStr = "truncate table internal.testcommand .tbl2 partition (" + partitionName + ");" ;
249
249
250
250
NereidsParser nereidsParser = new NereidsParser ();
251
251
LogicalPlan plan = nereidsParser .parseSingle (truncateStr );
0 commit comments