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

kxiao pushed a commit to branch branch-2.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.1 by this push:
     new c28c243c986 [Fix](Variant) forbit create variant as key #36555 (#36578)
c28c243c986 is described below

commit c28c243c986692814367e0bc7c07fdeccdee59d0
Author: lihangyu <15605149...@163.com>
AuthorDate: Thu Jun 20 20:33:48 2024 +0800

    [Fix](Variant) forbit create variant as key #36555 (#36578)
---
 .../plans/commands/info/ColumnDefinition.java      |  3 ++
 regression-test/suites/variant_p0/load.groovy      | 54 +++++++++++++++-------
 2 files changed, 40 insertions(+), 17 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
index 806aa7cd2aa..77d6040c216 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java
@@ -226,6 +226,9 @@ public class ColumnDefinition {
             } else if (type.isJsonType()) {
                 throw new AnalysisException(
                         "JsonType type should not be used in key column[" + 
getName() + "].");
+            } else if (type.isVariantType()) {
+                throw new AnalysisException(
+                        "Variant type should not be used in key column[" + 
getName() + "].");
             } else if (type.isMapType()) {
                 throw new AnalysisException("Map can only be used in the 
non-key column of"
                         + " the duplicate table at present.");
diff --git a/regression-test/suites/variant_p0/load.groovy 
b/regression-test/suites/variant_p0/load.groovy
index 899f7218b8e..572f7ce8ffc 100644
--- a/regression-test/suites/variant_p0/load.groovy
+++ b/regression-test/suites/variant_p0/load.groovy
@@ -255,23 +255,6 @@ suite("regression_test_variant", "nonConcurrent"){
         // b? 7.111  [123,{"xx":1}]  {"b":{"c":456,"e":7.111}}       456
         qt_sql_30 "select v['b']['e'], v['a'], v['b'], v['b']['c'] from 
jsonb_values where cast(v['b']['e'] as double) > 1;"
 
-        test {
-            sql "select v['a'] from ${table_name} group by v['a']"
-            exception("errCode = 2, detailMessage = Doris hll, bitmap, array, 
map, struct, jsonb, variant column must use with specific function, and don't 
support filter, group by or order by")
-        }
-
-        test {
-            sql """
-            create table var(
-                `content` variant
-            )distributed by hash(`content`) buckets 8
-            properties(
-              "replication_allocation" = "tag.location.default: 1"
-            );
-            """
-            exception("errCode = 2, detailMessage = Hash distribution info 
should not contain variant columns")
-        }
-
         // 13. sparse columns
         table_name = "sparse_columns"
         create_table table_name
@@ -440,6 +423,43 @@ suite("regression_test_variant", "nonConcurrent"){
         qt_sql_records3 """SELECT value FROM records WHERE   value['text99'] 
MATCH_ALL '来 广州 但是嗯嗯 还 不能 在'  OR (  value['text47'] MATCH_ALL '你 觉得 超 好看 的 动' ) 
OR (  value['text43'] MATCH_ALL ' 楼主 拒绝 了 一个 女生 我 傻逼 吗手' )  LIMIT 0, 100"""
         qt_sql_records4 """SELECT value FROM records WHERE  value['id16'] = 
'39960' AND (  value['text59'] = '非 明显 是 一 付 很 嫌') AND (  value['text99'] = '来 
广州 但是嗯嗯 还 不能 在 ')  """
         qt_sql_records5 """SELECT value FROM records WHERE  value['text3'] 
MATCH_ALL '伊心 是 来 搞笑 的'  LIMIT 0, 100"""
+
+        test {
+            sql "select v['a'] from ${table_name} group by v['a']"
+            exception("errCode = 2, detailMessage = Doris hll, bitmap, array, 
map, struct, jsonb, variant column must use with specific function, and don't 
support filter, group by or order by")
+        }
+
+        test {
+            sql """
+            create table var(
+                `key` int,
+                `content` variant
+            )
+            DUPLICATE KEY(`key`)
+            distributed by hash(`content`) buckets 8
+            properties(
+              "replication_allocation" = "tag.location.default: 1"
+            );
+            """
+            exception("errCode = 2, detailMessage = Hash distribution info 
should not contain variant columns")
+        }
+
+         test {
+            sql """
+            CREATE TABLE `var_as_key` (
+              `key` int NULL,
+              `var` variant NULL
+            ) ENGINE=OLAP
+            DUPLICATE KEY(`key`, `var`)
+            COMMENT 'OLAP'
+            DISTRIBUTED BY RANDOM BUCKETS 1
+            PROPERTIES (
+            "replication_allocation" = "tag.location.default: 1"
+            );
+            """ 
+            exception("errCode = 2, detailMessage = Variant type should not be 
used in key")
+        }
+
     } finally {
         // reset flags
         set_be_config.call("variant_ratio_of_defaults_as_sparse_column", 
"0.95")


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

Reply via email to