morningman commented on a change in pull request #8142:
URL: https://github.com/apache/incubator-doris/pull/8142#discussion_r810114730



##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Type.java
##########
@@ -659,6 +659,36 @@ public Integer getColumnSize() {
         }
     }
 
+    /**
+     * For schema change, convert data type to string,
+     * get the size of string representation
+     */
+    public Integer getColumnStringRepSize() {

Review comment:
       I think the BE side also needs to have a self-defense mechanism to 
ensure that when the FE does not judge the length correctly, it will not cause 
the BE to crash?

##########
File path: fe/fe-core/src/main/java/org/apache/doris/catalog/Column.java
##########
@@ -386,6 +386,14 @@ public void checkSchemaChangeAllowed(Column other) throws 
DdlException {
             throw new DdlException("Can not change " + getDataType() + " to " 
+ other.getDataType());
         }
 
+        if (type.isNumericType() && other.type.isStringType()) {
+            Integer lSize = type.getColumnStringRepSize();
+            Integer rSize = other.type.getColumnStringRepSize();
+            if (rSize < lSize) {
+                throw new DdlException("Can not change from wider type to 
narrower type");

Review comment:
       Add more detail info in error msg, such as column name, lSize, rSize.
   So that user can easy debugging.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to