This is an automated email from the ASF dual-hosted git repository.

xuyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 87e5e2b48b [Fix](array-type) Disable schema change between array type 
columns (#13261)
87e5e2b48b is described below

commit 87e5e2b48b1812a330c6bad096df6f666a554cb3
Author: xy720 <22125576+xy...@users.noreply.github.com>
AuthorDate: Thu Oct 13 22:59:09 2022 +0800

    [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.
---
 fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java | 5 +++++
 fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java
index 7b63796548..eab1da07dd 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/ColumnType.java
@@ -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) {
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java
index d3b80bbc90..45e4df0658 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/ColumnTest.java
@@ -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.");
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to