[Fix](array-type) Disable schema change between array type columns (#13261)

Currently, we do not support schema change between array type columns.
We should forbid users from doing this operation.
This commit is contained in:
xy720
2022-10-13 22:59:09 +08:00
committed by GitHub
parent de4315c1c5
commit 87e5e2b48b
2 changed files with 13 additions and 0 deletions

View File

@ -153,6 +153,11 @@ public abstract class ColumnType {
// we should support schema change between different precision
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;
}
static boolean isSchemaChangeAllowed(Type lhs, Type rhs) {

View File

@ -142,4 +142,12 @@ public class ColumnTest {
oldColumn.checkSchemaChangeAllowed(newColumn);
Assert.fail("No exception throws.");
}
@Test(expected = DdlException.class)
public void testSchemaChangeArrayToArray() throws DdlException {
Column oldColumn = new Column("a", ArrayType.create(Type.TINYINT, true), false, null, true, "0", "");
Column newColumn = new Column("a", ArrayType.create(Type.INT, true), false, null, true, "0", "");
oldColumn.checkSchemaChangeAllowed(newColumn);
Assert.fail("No exception throws.");
}
}