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

yiguolei 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 b1c2a8343f [Bug](array_type) Forbid adding array key columns #12479
b1c2a8343f is described below

commit b1c2a8343f429baebf5aa5cc6e7dec7749983bab
Author: xy720 <22125576+xy...@users.noreply.github.com>
AuthorDate: Tue Sep 13 08:48:28 2022 +0800

    [Bug](array_type) Forbid adding array key columns #12479
    
    mysql> desc array_test;
    +-----------+----------------+------+-------+---------+-------+
    | Field     | Type           | Null | Key   | Default | Extra |
    +-----------+----------------+------+-------+---------+-------+
    | id        | INT            | Yes  | true  | NULL    |       |
    | c_array   | ARRAY<INT(11)> | Yes  | false | NULL    | NONE  |
    +-----------+----------------+------+-------+---------+-------+
    
    Before:
    mysql> ALTER TABLE array_test ADD COLUMN add_arr_key array<int> key NULL 
DEFAULT NULL;
    Query OK, 0 rows affected (0.00 sec)
    
    After:
    mysql> ALTER TABLE array_test ADD COLUMN c_array array<int> key NULL 
DEFAULT NULL;
    ERROR 1105 (HY000): errCode = 2, detailMessage = Array can only be used in 
the non-key column of the duplicate table at present.
    
    mysql> ALTER TABLE array_test MODIFY COLUMN c_array array<int> key NULL 
DEFAULT NULL;
    ERROR 1105 (HY000): errCode = 2, detailMessage = Array can only be used in 
the non-key column of the duplicate table at present.
---
 fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java 
b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
index 788b5e59f1..5a944aa7b2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/ColumnDef.java
@@ -265,6 +265,10 @@ public class ColumnDef {
         }
 
         if (type.getPrimitiveType() == PrimitiveType.ARRAY) {
+            if (isKey()) {
+                throw new AnalysisException("Array can only be used in the 
non-key column of"
+                    + " the duplicate table at present.");
+            }
             if (defaultValue.isSet && defaultValue != 
DefaultValue.NULL_DEFAULT_VALUE) {
                 throw new AnalysisException("Array type column default value 
only support null");
             }


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

Reply via email to