morrySnow commented on code in PR #31893:
URL: https://github.com/apache/doris/pull/31893#discussion_r1616512303


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/DropCatalogRecycleBinInfo.java:
##########
@@ -0,0 +1,91 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.nereids.trees.plans.commands.info;
+
+import org.apache.doris.nereids.exceptions.AnalysisException;
+import org.apache.doris.qe.ConnectContext;
+
+/**
+ * drop catalog recycle db/table/partition info
+ */
+public class DropCatalogRecycleBinInfo {
+
+    private String idType;

Review Comment:
   use enum to avoid write too many idType.equalsIgnoreCase. then u could only 
use one id attr to represent diff type id according to idType



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/InternalCatalog.java:
##########
@@ -708,6 +709,22 @@ public void recoverPartition(RecoverPartitionStmt 
recoverStmt) throws DdlExcepti
         }
     }
 
+    public void dropCatalogRecycleBin(DropCatalogRecycleBinInfo dropInfo) 
throws DdlException {
+        if (dropInfo.getIdType().equalsIgnoreCase("'DbId'")
+                || dropInfo.getIdType().equalsIgnoreCase("\"DbId\"")) {
+            
Env.getCurrentRecycleBin().eraseDatabaseInstantly(dropInfo.getDbId());
+            LOG.info("drop database[{}] in catalog recycle bin", 
dropInfo.getDbId());
+        } else if (dropInfo.getIdType().equalsIgnoreCase("'TableId'")
+                || dropInfo.getIdType().equalsIgnoreCase("\"TableId\"")) {
+            
Env.getCurrentRecycleBin().eraseTableInstantly(dropInfo.getTableId());
+            LOG.info("drop table[{}] in catalog recycle bin", 
dropInfo.getTableId());
+        } else if (dropInfo.getIdType().equalsIgnoreCase("'PartitionId'")
+                || dropInfo.getIdType().equalsIgnoreCase("\"PartitionId\"")) {
+            
Env.getCurrentRecycleBin().erasePartitionInstantly(dropInfo.getPartitionId());
+            LOG.info("drop partition[{}] in catalog recycle bin", 
dropInfo.getPartitionId());
+        }

Review Comment:
   when u use enum then u could write like:
   ```java
   switch (dropInfo.getIdType()) {
     case DATABASE_ID:
       Env.getCurrentRecycleBin().eraseDatabaseInstantly(dropInfo.getId());
       LOG.info("drop database[{}] in catalog recycle bin", dropInfo.getId());
       break;
     ...
   }
   ```



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java:
##########
@@ -3543,6 +3546,14 @@ public LogicalPlan 
visitShowCreateProcedure(ShowCreateProcedureContext ctx) {
         return ParserUtils.withOrigin(ctx, () -> new 
ShowCreateProcedureCommand(procedureName));
     }
 
+    @Override
+    public LogicalPlan visitDropCatalogRecycleBin(DropCatalogRecycleBinContext 
ctx) {
+        String idType = String.valueOf(ctx.idType.getText());

Review Comment:
   `ctx.idType.getText().substring(1, ctx.idType.getText().length() - 1)`
   then u will get string without quotes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to