eldenmoon commented on code in PR #47096:
URL: https://github.com/apache/doris/pull/47096#discussion_r1994653438
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java:
##########
@@ -208,12 +210,48 @@ public static void
checkSupportSchemaChangeForComplexType(Type checkType, Type o
if (checkType.isStructType() && other.isStructType()) {
StructType thisStructType = (StructType) checkType;
StructType otherStructType = (StructType) other;
- if (thisStructType.getFields().size() !=
otherStructType.getFields().size()) {
- throw new DdlException("Cannot change struct type with
different field size");
+ // now we only support add new field for struct type
+ if (thisStructType.getFields().size() >
otherStructType.getFields().size()) {
+ throw new DdlException("Cannot reduce struct fields from " +
checkType.toSql() + " to "
+ + other.toSql());
}
- for (int i = 0; i < thisStructType.getFields().size(); i++) {
+ int i = 0;
+ HashSet<String> thisStructNames = new HashSet<>();
+ for (; i < thisStructType.getFields().size(); i++) {
+ // do not support struct same position field name/type change
+ StructField thisField = thisStructType.getFields().get(i);
+ StructField otherField = otherStructType.getFields().get(i);
+ if (!thisField.equals(otherField)) {
+ // name and type are changed will throw exception
Review Comment:
too many nested if else, need refator
--
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]