This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new ffe1af359ae [Improve](Variant) Add more static type constraints to
ensure the safety of predefined types in Variant. (#52799)
ffe1af359ae is described below
commit ffe1af359aef9f018587496d7102b8626d0cd2cd
Author: lihangyu <[email protected]>
AuthorDate: Tue Jul 8 17:40:12 2025 +0800
[Improve](Variant) Add more static type constraints to ensure the safety of
predefined types in Variant. (#52799)
---
.../main/java/org/apache/doris/catalog/Type.java | 1 -
.../java/org/apache/doris/catalog/VariantType.java | 5 +
.../suites/variant_p0/predefine/multi_var.groovy | 9 +-
.../variant_p0/predefine/test_predefine_ddl.groovy | 357 +++++++--------------
4 files changed, 128 insertions(+), 244 deletions(-)
diff --git a/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
b/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
index 0f4167620a3..83ce0fb654c 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/Type.java
@@ -286,7 +286,6 @@ public abstract class Type {
variantSubTypes.add(IPV4);
variantSubTypes.add(IPV6);
variantSubTypes.add(STRING);
- variantSubTypes.add(ARRAY);
variantSubTypes.add(NULL);
}
diff --git
a/fe/fe-common/src/main/java/org/apache/doris/catalog/VariantType.java
b/fe/fe-common/src/main/java/org/apache/doris/catalog/VariantType.java
index 8cdc694c492..a173cf8aa50 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/catalog/VariantType.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/catalog/VariantType.java
@@ -86,6 +86,11 @@ public class VariantType extends ScalarType {
@Override
public boolean supportSubType(Type subType) {
for (Type supportedType : Type.getVariantSubTypes()) {
+ // Only one level of array is supported
+ if (subType.getPrimitiveType() == PrimitiveType.ARRAY
+ && ((ArrayType) subType).getItemType().getPrimitiveType()
!= PrimitiveType.ARRAY) {
+ return supportSubType(((ArrayType) subType).getItemType());
+ }
if (subType.getPrimitiveType() ==
supportedType.getPrimitiveType()) {
return true;
}
diff --git a/regression-test/suites/variant_p0/predefine/multi_var.groovy
b/regression-test/suites/variant_p0/predefine/multi_var.groovy
index a31451207b3..411b826ef50 100644
--- a/regression-test/suites/variant_p0/predefine/multi_var.groovy
+++ b/regression-test/suites/variant_p0/predefine/multi_var.groovy
@@ -16,14 +16,13 @@
// under the License.
suite("regression_test_variant_predefine_multi_var", "variant_type"){
- // int max_subcolumns_count = Math.floor(Math.random() * 7)
- int max_subcolumns_count = 3
+ int max_subcolumns_count = Math.floor(Math.random() * 7) + 1
def table_name = "multi_variants"
sql "DROP TABLE IF EXISTS ${table_name}"
sql """
CREATE TABLE IF NOT EXISTS ${table_name} (
k bigint,
- v variant<'k1' : int, 'k2' : string, 'k3' : array<int>, 'k4' :
double, 'k5' : array<array<int>>>,
+ v variant<'k1' : int, 'k2' : string, 'k3' : array<int>, 'k4' :
double>,
)
DUPLICATE KEY(`k`)
DISTRIBUTED BY HASH(k) BUCKETS 4
@@ -33,9 +32,9 @@ suite("regression_test_variant_predefine_multi_var",
"variant_type"){
sql """INSERT INTO ${table_name} SELECT *, '{"k7":123, "k8": "elden ring",
"k9" : 1.1112, "k10" : [1.12], "k11" : ["moon"]}' FROM numbers("number" =
"203") where number > 100"""
sql """INSERT INTO ${table_name} SELECT *, '{"k7":123, "k8": "elden ring",
"k9" : 1.1112, "k10" : [1.12], "k11" : ["moon"]}' FROM numbers("number" =
"411") where number > 200"""
trigger_and_wait_compaction(table_name, "cumulative")
- sql "alter table ${table_name} add column v2 variant<'k1' : int, 'k2' :
string, 'k3' : array<int>, 'k4' : double, 'k5' : array<array<int>>> default
null"
+ sql "alter table ${table_name} add column v2 variant<'k1' : int, 'k2' :
string, 'k3' : array<int>, 'k4' : double> default null"
sql """INSERT INTO ${table_name} select k, v, v from ${table_name}"""
- sql "alter table ${table_name} add column v3 variant<'k1' : int, 'k2' :
string, 'k3' : array<int>, 'k4' : double, 'k5' : array<array<int>>> default
null"
+ sql "alter table ${table_name} add column v3 variant<'k1' : int, 'k2' :
string, 'k3' : array<int>, 'k4' : double> default null"
sql """INSERT INTO ${table_name} select k, v, v, v from ${table_name}"""
sql "alter table ${table_name} add column ss string default null"
sql """INSERT INTO ${table_name} select k, v, v, v, v from ${table_name}"""
diff --git
a/regression-test/suites/variant_p0/predefine/test_predefine_ddl.groovy
b/regression-test/suites/variant_p0/predefine/test_predefine_ddl.groovy
index 37f16d25722..a029144792d 100644
--- a/regression-test/suites/variant_p0/predefine/test_predefine_ddl.groovy
+++ b/regression-test/suites/variant_p0/predefine/test_predefine_ddl.groovy
@@ -17,11 +17,9 @@
suite("test_predefine_ddl", "p0"){
- def tableName = "test_ddl_table"
- boolean findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
+ test {
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant<
MATCH_NAME 'ab' : string,
@@ -35,145 +33,78 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_bx_glob (var) USING INVERTED
PROPERTIES("field_pattern"="bx?", "parser"="unicode", "support_phrase" =
"true") COMMENT ''
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("can not find field pattern: bb* in
column: var"))
- findException = true
+ exception("can not find field pattern: bb* in column: var")
}
- assertTrue(findException)
-
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
- `id` bigint NULL,
- `var` variant<
- MATCH_NAME 'ab' : string,
- MATCH_NAME '*cc' : string,
- MATCH_NAME 'b?b' : string
- > NOT NULL,
- INDEX idx_a_b (var) USING INVERTED
PROPERTIES("field_pattern"="ab", "parser"="unicode", "support_phrase" = "true")
COMMENT '',
- ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
- BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- findException = true
- }
- assertFalse(findException)
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
+ `id` bigint NULL,
+ `var` variant<
+ MATCH_NAME 'ab' : string,
+ MATCH_NAME '*cc' : string,
+ MATCH_NAME 'b?b' : string
+ > NOT NULL,
+ INDEX idx_a_b (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT '',
+ ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
+ BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default:
1", "disable_auto_compaction" = "true")"""
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
+ test {
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant NOT NULL,
INDEX idx_a_b (var) USING INVERTED
PROPERTIES("field_pattern"="ab", "parser"="unicode", "support_phrase" = "true")
COMMENT '',
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("can not find field pattern: ab in
column: var"))
- findException = true
+ exception("can not find field pattern: ab in column: var")
}
- assertTrue(findException)
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
- `id` bigint NULL,
- `var` variant NULL
- ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
- BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- findException = true
- }
- assertFalse(findException)
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
+ `id` bigint NULL,
+ `var` variant NULL
+ ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
+ BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default:
1", "disable_auto_compaction" = "true")"""
- findException = false
- try {
- sql """ create index idx_ab on ${tableName} (var) using inverted
properties("field_pattern"="ab", "parser"="unicode", "support_phrase" = "true")
"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("Can not create index with field
pattern"))
- findException = true
+ test {
+ sql """ create index idx_ab on test_ddl_table (var) using inverted
properties("field_pattern"="ab", "parser"="unicode", "support_phrase" = "true")
"""
+ exception("Can not create index with field pattern")
}
- assertTrue(findException)
+ sql """ alter table test_ddl_table add column var2 variant<'ab' : string>
NULL """
- findException = false
- try {
- sql """ alter table ${tableName} add column var2 variant<'ab' :
string> NULL """
- } catch (Exception e) {
- log.info(e.getMessage())
- findException = true
+ test {
+ sql """ alter table test_ddl_table modify column var variant<'ab' :
string> NULL """
+ exception("Can not modify variant column with children")
}
- assertFalse(findException)
- findException = false
- try {
- sql """ alter table ${tableName} modify column var variant<'ab' :
string> NULL """
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("Can not modify variant column with
children"))
- findException = true
- }
- assertTrue(findException)
-
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
- `id` bigint NULL,
- `var` variant<
- MATCH_NAME 'ab' : string,
- MATCH_NAME '*cc' : string,
- MATCH_NAME 'b?b' : string
- > NULL,
- INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT ''
- ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
- BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- findException = true
- }
- assertFalse(findException)
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
+ `id` bigint NULL,
+ `var` variant<
+ MATCH_NAME 'ab' : string,
+ MATCH_NAME '*cc' : string,
+ MATCH_NAME 'b?b' : string
+ > NULL,
+ INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT ''
+ ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
+ BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default:
1", "disable_auto_compaction" = "true")"""
- findException = false
- try {
- sql """ alter table ${tableName} modify column var variant NULL """
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("Can not modify variant column with
children"))
- findException = true
+ test {
+ sql """ alter table test_ddl_table modify column var variant NULL """
+ exception("Can not modify variant column with children")
}
- assertTrue(findException)
- findException = false
- try {
- sql """ alter table ${tableName} drop index idx_ab """
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("Can not drop index with field
pattern"))
- findException = true
+ test {
+ sql """ alter table test_ddl_table drop index idx_ab """
+ exception("Can not drop index with field pattern")
}
- assertTrue(findException)
- findException = false
- try {
- sql """ alter table ${tableName} drop column var """
- } catch (Exception e) {
- log.info(e.getMessage())
- findException = true
- }
- assertFalse(findException)
+ sql """ alter table test_ddl_table drop column var """
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
+ test {
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant<
MATCH_NAME 'ab' : json
@@ -181,17 +112,12 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT ''
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("VARIANT unsupported sub-type:
json"))
- findException = true
+ exception("VARIANT unsupported sub-type: json")
}
- assertTrue(findException)
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
+ test {
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant<
MATCH_NAME 'ab' : int,
@@ -200,83 +126,56 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT ''
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("Duplicate field name ab in struct
variant<MATCH_NAME 'ab':int,MATCH_NAME 'ab':text>"))
- findException = true
+ exception("Duplicate field name ab in struct variant<MATCH_NAME
'ab':int,MATCH_NAME 'ab':text>")
}
- assertTrue(findException)
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
+ test {
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant<
MATCH_NAME 'ab' : decimalv2(22, 2)
> NULL
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("VARIANT unsupported sub-type:
decimalv2(22,2)"))
- findException = true
+ exception("VARIANT unsupported sub-type: decimalv2(22,2)")
}
- assertTrue(findException)
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
+ test {
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant<
MATCH_NAME 'ab' : datev1
> NULL
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("VARIANT unsupported sub-type:
date"))
- findException = true
+ exception("VARIANT unsupported sub-type: date")
}
- assertTrue(findException)
- findException = false
- try {
- sql "DROP TABLE IF EXISTS ${tableName}"
- sql """CREATE TABLE ${tableName} (
+ test {
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant<
MATCH_NAME 'ab' : datetimev1
> NULL
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("VARIANT unsupported sub-type:
datetime"))
- findException = true
+ exception("VARIANT unsupported sub-type: datetime")
}
- assertTrue(findException)
- findException = false
- try {
- sql "DROP TABLE IF EXISTS test_ddl_table"
- sql """CREATE TABLE test_ddl_table (
- `id` bigint NULL,
- `var` variant<
- MATCH_NAME 'ab' : double
- > NULL,
- INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT ''
- ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
- BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- findException = true
- }
- assertFalse(findException)
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
+ `id` bigint NULL,
+ `var` variant<
+ MATCH_NAME 'ab' : double
+ > NULL,
+ INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT ''
+ ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
+ BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default:
1", "disable_auto_compaction" = "true")"""
- findException = false
- try {
+ test {
sql "DROP TABLE IF EXISTS test_ddl_table"
sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
@@ -287,33 +186,21 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_ab_2 (var) USING INVERTED
PROPERTIES("field_pattern"="ab") COMMENT ''
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("column: var cannot have multiple
inverted indexes with field pattern: ab"))
- findException = true
+ exception("column: var cannot have multiple inverted indexes with
field pattern: ab")
}
- assertTrue(findException)
- findException = false
- try {
- sql "DROP TABLE IF EXISTS test_ddl_table"
- sql """CREATE TABLE test_ddl_table (
- `id` bigint NULL,
- `var` variant<
- MATCH_NAME 'ab' : string
- > NULL,
- INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT '',
- INDEX idx_ab_2 (var) USING INVERTED
PROPERTIES("field_pattern"="ab") COMMENT ''
- ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
- BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- findException = true
- }
- assertFalse(findException)
+ sql "DROP TABLE IF EXISTS test_ddl_table"
+ sql """CREATE TABLE test_ddl_table (
+ `id` bigint NULL,
+ `var` variant<
+ MATCH_NAME 'ab' : string
+ > NULL,
+ INDEX idx_ab (var) USING INVERTED PROPERTIES("field_pattern"="ab",
"parser"="unicode", "support_phrase" = "true") COMMENT '',
+ INDEX idx_ab_2 (var) USING INVERTED PROPERTIES("field_pattern"="ab")
COMMENT ''
+ ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
+ BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default:
1", "disable_auto_compaction" = "true")"""
- findException = false
- try {
+ test {
sql "DROP TABLE IF EXISTS test_ddl_table"
sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
@@ -324,15 +211,10 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_ab_2 (var) USING INVERTED
PROPERTIES("field_pattern"="ab", "parser"="unicode", "support_phrase" = "true")
COMMENT ''
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("column: var cannot have multiple
inverted indexes with field pattern: ab"))
- findException = true
+ exception("column: var cannot have multiple inverted indexes with
field pattern: ab")
}
- assertTrue(findException)
- findException = false
- try {
+ test {
sql "DROP TABLE IF EXISTS test_ddl_table"
sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
@@ -343,15 +225,10 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_ab_2 (var) USING INVERTED
PROPERTIES("field_pattern"="ab") COMMENT ''
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("column: var cannot have multiple
inverted indexes with field pattern: ab"))
- findException = true
+ exception("column: var cannot have multiple inverted indexes with
field pattern: ab")
}
- assertTrue(findException)
- findException = false
- try {
+ test {
sql "DROP TABLE IF EXISTS test_ddl_table"
sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
@@ -362,15 +239,10 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_ab_2 (var) USING INVERTED
PROPERTIES("field_pattern"="ab") COMMENT ''
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("column: var cannot have multiple
inverted indexes with field pattern: ab"))
- findException = true
+ exception("column: var cannot have multiple inverted indexes with
field pattern: ab")
}
- assertTrue(findException)
- findException = false
- try {
+ test {
sql "DROP TABLE IF EXISTS test_ddl_table"
sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
@@ -379,24 +251,33 @@ suite("test_predefine_ddl", "p0"){
INDEX idx_ab_2 (var) USING INVERTED
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true",
"inverted_index_storage_format" = "v1")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("column: var cannot have multiple
inverted indexes with file storage format: V1"))
- findException = true
+ exception("column: var cannot have multiple inverted indexes with file
storage format: V1")
}
- assertTrue(findException)
- findException = false
- try {
+ test {
sql """CREATE TABLE test_ddl_table (
`id` bigint NULL,
`var` variant <'c' :char(10)> NULL
) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true",
"inverted_index_storage_format" = "v1")"""
- } catch (Exception e) {
- log.info(e.getMessage())
- assertTrue(e.getMessage().contains("VARIANT unsupported sub-type:
char(10)"))
- findException = true
+ exception("VARIANT unsupported sub-type: char(10)")
+ }
+
+ test {
+ sql """CREATE TABLE test_ddl_table (
+ `id` bigint NULL,
+ `var` variant <'c' :array<char(10)>> NULL
+ ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
+ BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true",
"inverted_index_storage_format" = "v1")"""
+ exception("VARIANT unsupported sub-type: array<char(10)>")
+ }
+
+ test {
+ sql """CREATE TABLE test_ddl_table (
+ `id` bigint NULL,
+ `var` variant <'c' :array<array<int>>> NULL
+ ) ENGINE=OLAP DUPLICATE KEY(`id`) DISTRIBUTED BY HASH(`id`)
+ BUCKETS 1 PROPERTIES ( "replication_allocation" =
"tag.location.default: 1", "disable_auto_compaction" = "true",
"inverted_index_storage_format" = "v1")"""
+ exception("VARIANT unsupported sub-type: array<array<int>>")
}
- assertTrue(findException)
}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]