[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:
@ -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) {
|
||||
|
||||
@ -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.");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user