TangSiyang2001 commented on code in PR #48025: URL: https://github.com/apache/doris/pull/48025#discussion_r2011552101
########## fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java: ########## @@ -168,6 +169,72 @@ static boolean isSchemaChangeAllowed(Type lhs, Type rhs) { return schemaChangeMatrix[lhs.getPrimitiveType().ordinal()][rhs.getPrimitiveType().ordinal()]; } + /** + * Used for checking type length changing. + * Currently, type length is only meaningful for string types{@link Type#isStringType()}, + * see {@link ScalarType#len}. + */ + public static void checkForTypeLengthChange(Type src, Type dst) throws DdlException { + final int srcTypeLen = src.getLength(); + final int dstTypeLen = dst.getLength(); + if (srcTypeLen < 0 || dstTypeLen < 0) { + // type length is negative means that it is meaningless, just return + return; + } + if (srcTypeLen > dstTypeLen) { + throw new DdlException( + String.format("Shorten type length is prohibited, srcType=%s, dstType=%s", src.toSql(), dst.toSql())); + } + } + + // This method defines the char type + // to support the schema-change behavior of length growth. + // return true if the checkType and other are both char-type otherwise return false, + // which used in checkSupportSchemaChangeForComplexType + private static boolean checkSupportSchemaChangeForCharType(Type checkType, Type other) throws DdlException { + if (checkType.isStringType() && other.isStringType()) { + checkForTypeLengthChange(checkType, other); + return true; Review Comment: pick #49452 to fix problem here. Currently nested types only support light schema change for internal fields, for string types, only varchar can do light schema change. Enlarging length for `char`, modifying from char to varchar and modifying from varchar to char should be forbidden. -- 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