You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/10/19 12:19:06 UTC

[GitHub] [doris] dataroaring commented on a diff in pull request #13410: [feature](alter) support rename column for table with unique column id

dataroaring commented on code in PR #13410:
URL: https://github.com/apache/doris/pull/13410#discussion_r999365287


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java:
##########
@@ -4030,12 +4031,113 @@ public void replayRenamePartition(TableInfo tableInfo) throws MetaNotFoundExcept
         }
     }
 
+    public void renameColumn(Database db, OlapTable table, String colName,
+            String newColName, boolean isReplay) throws DdlException {
+        if (table.getState() != OlapTableState.NORMAL) {
+            throw new DdlException("Table[" + table.getName() + "] is under " + table.getState());
+        }
+
+        if (colName.equalsIgnoreCase(newColName)) {
+            throw new DdlException("Same column name");
+        }
+
+        Map<Long, MaterializedIndexMeta> indexIdToMeta = table.getIndexIdToMeta();
+        for (Map.Entry<Long, MaterializedIndexMeta> entry : indexIdToMeta.entrySet()) {
+            // rename column is not implemented for table without column unique id.
+            if (entry.getValue().getMaxColUniqueId() < 0) {
+                throw new DdlException("not implemented for table without column unique id");

Review Comment:
   same as before, users do not know what is column unique id, they know property in create table statement.



##########
docs/en/docs/sql-manual/sql-reference/Data-Definition-Statements/Alter/ALTER-TABLE-RENAME.md:
##########
@@ -66,6 +66,18 @@ grammar:
 RENAME PARTITION old_partition_name new_partition_name;
 ```
 
+4. Modify the column name
+
+grammar:
+
+```sql
+RENAME COLUMN old_column_name new_column_name;
+```
+
+Notice:
+- Currently only tables with column unique id are supported
+

Review Comment:
   Currently only tables with column unique id are supported, which are created with property 'light_schema_change'.



-- 
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-unsubscribe@doris.apache.org

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


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