amorynan commented on code in PR #46639:
URL: https://github.com/apache/doris/pull/46639#discussion_r1909762431


##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java:
##########
@@ -888,12 +883,14 @@ public void checkSchemaChangeAllowed(Column other) throws 
DdlException {
             }
         }
 
-        if ((getDataType() == PrimitiveType.VARCHAR && other.getDataType() == 
PrimitiveType.VARCHAR) || (
-                getDataType() == PrimitiveType.CHAR && other.getDataType() == 
PrimitiveType.VARCHAR) || (
-                getDataType() == PrimitiveType.CHAR && other.getDataType() == 
PrimitiveType.CHAR)) {
-            if (getStrLen() > other.getStrLen()) {
-                throw new DdlException("Cannot shorten string length");
+        // Nested types only support changing the order and increasing the 
length of the nested char type
+        // Char-type only support length growing
+        try {
+            if (!type.isSupportSchemaChangeForComplexType(other.type)) {

Review Comment:
   done!



##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -629,8 +630,23 @@ private boolean processModifyColumn(ModifyColumnClause 
alterClause, OlapTable ol
                     // TODO:the case where columnPos is not empty has not been 
considered
                     if (columnPos == null && col.getDataType() == 
PrimitiveType.VARCHAR
                             && modColumn.getDataType() == 
PrimitiveType.VARCHAR) {
-                        col.checkSchemaChangeAllowed(modColumn);
-                        lightSchemaChange = 
olapTable.getEnableLightSchemaChange();
+                        try {
+                            if 
(col.getType().isSupportSchemaChangeForCharType(modColumn.getType())) {

Review Comment:
   done!



##########
fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java:
##########
@@ -523,6 +523,48 @@ public boolean isDecimalV3OrContainsDecimalV3() {
         return false;
     }
 
+    // This method defines the char type
+    // to support the schema-change behavior of length growth.
+    public boolean isSupportSchemaChangeForCharType(Type other) throws 
TypeException {
+        if ((this.getPrimitiveType() == PrimitiveType.VARCHAR && 
other.getPrimitiveType() == PrimitiveType.VARCHAR) || (
+                this.getPrimitiveType() == PrimitiveType.CHAR && 
other.getPrimitiveType() == PrimitiveType.VARCHAR) || (
+                this.getPrimitiveType() == PrimitiveType.CHAR && 
other.getPrimitiveType() == PrimitiveType.CHAR)) {
+            if (this.getLength() > other.getLength()) {
+                throw new TypeException("Cannot shorten string length");
+            } else {
+                return true;

Review Comment:
   done!



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