[fix](nestedtype) support nested type for schema change reorder (#39392)

## Proposed changes
backport: https://github.com/apache/doris/pull/39210
Issue Number: close #xxx

<!--Describe your changes.-->
This commit is contained in:
amory
2024-08-15 14:03:03 +08:00
committed by GitHub
parent acf07cab6f
commit 1accde9fb3
7 changed files with 2329 additions and 33 deletions

View File

@ -648,6 +648,11 @@ public class Column implements Writable, GsonPostProcessable {
throw new DdlException("Dest column name is empty");
}
// now nested type can only support change order
if (type.isComplexType() && !type.equals(other.type)) {
throw new DdlException("Can not change " + type + " to " + other);
}
if (!ColumnType.isSchemaChangeAllowed(type, other.type)) {
throw new DdlException("Can not change " + getDataType() + " to " + other.getDataType());
}

View File

@ -156,9 +156,9 @@ public abstract class ColumnType {
schemaChangeMatrix[PrimitiveType.DATETIMEV2.ordinal()][PrimitiveType.DATETIMEV2.ordinal()] = true;
// Currently, we do not support schema change between complex types with subtypes.
schemaChangeMatrix[PrimitiveType.ARRAY.ordinal()][PrimitiveType.ARRAY.ordinal()] = false;
schemaChangeMatrix[PrimitiveType.STRUCT.ordinal()][PrimitiveType.STRUCT.ordinal()] = false;
schemaChangeMatrix[PrimitiveType.MAP.ordinal()][PrimitiveType.MAP.ordinal()] = false;
schemaChangeMatrix[PrimitiveType.ARRAY.ordinal()][PrimitiveType.ARRAY.ordinal()] = true;
schemaChangeMatrix[PrimitiveType.STRUCT.ordinal()][PrimitiveType.STRUCT.ordinal()] = true;
schemaChangeMatrix[PrimitiveType.MAP.ordinal()][PrimitiveType.MAP.ordinal()] = true;
}
static boolean isSchemaChangeAllowed(Type lhs, Type rhs) {