HappenLee commented on a change in pull request #4699:
URL: https://github.com/apache/incubator-doris/pull/4699#discussion_r500816484



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Catalog.java
##########
@@ -5045,6 +5046,36 @@ public void renameTable(Database db, OlapTable table, 
TableRenameClause tableRen
         LOG.info("rename table[{}] to {}", tableName, newTableName);
     }
 
+    public void renameTable(Database db, Table table, TableRenameClause 
tableRenameClause) throws DdlException {
+        String tableName = table.getName();
+        String newTableName = tableRenameClause.getNewTableName();
+        if (tableName.equals(newTableName)) {
+            throw new DdlException("Same table name");
+        }
+
+        // check if name is already used
+        if (db.getTable(newTableName) != null) {
+            throw new DdlException("Table name[" + newTableName + "] is 
already used");
+        }
+
+        table.setName(newTableName);
+
+        db.dropTable(tableName);
+        db.createTable(table);
+
+        TableInfo tableInfo = TableInfo.createForTableRename(db.getId(), 
table.getId(), newTableName);
+        editLog.logTableRename(tableInfo);
+        LOG.info("rename table[{}] to {}", tableName, newTableName);
+    }
+
+    public void reflushTable(Database db, Table table) throws DdlException {

Review comment:
       yes,to make sure it is atomic. We may need add a new OperationType in 
edit log.




----------------------------------------------------------------
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.

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