Skip to content

Commit

Permalink
[fix](variant) disable column name with dot character for variant type (
Browse files Browse the repository at this point in the history
#45927)

Variant type column named with '.' character make be crashed, here
disable it temporarily.
  • Loading branch information
cambyzju authored and Your Name committed Dec 26, 2024
1 parent 4705087 commit f4e6061
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ public void analyze(Analyzer analyzer) throws UserException {
throw new AnalysisException(
"Disable to create table column with name start with __DORIS_: " + columnNameUpperCase);
}
if (Objects.equals(columnDef.getType(), Type.VARIANT) && columnNameUpperCase.indexOf('.') != -1) {
throw new AnalysisException(
"Disable to create table of `VARIANT` type column named with a `.` character: "
+ columnNameUpperCase);
}
if (Objects.equals(columnDef.getType(), Type.DATE) && Config.disable_datev1) {
throw new AnalysisException("Disable to create table with `DATE` type columns, please use `DATEV2`.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ public void validate(ConnectContext ctx) {
throw new AnalysisException(
"Disable to create table column with name start with __DORIS_: " + columnNameUpperCase);
}
if (columnDef.getType().isVariantType() && columnNameUpperCase.indexOf('.') != -1) {
throw new AnalysisException(
"Disable to create table of `VARIANT` type column named with a `.` character: "
+ columnNameUpperCase);
}
if (columnDef.getType().isDateType() && Config.disable_datev1) {
throw new AnalysisException(
"Disable to create table with `DATE` type columns, please use `DATEV2`.");
Expand Down
30 changes: 30 additions & 0 deletions regression-test/suites/ddl_p0/test_create_table.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ suite("sql_create_time_range_table") {
);
"""

// variant type column named with '.' character is disabled
sql "DROP TABLE IF EXISTS disable_variant_column_with_dot"
test {
sql """
CREATE TABLE disable_variant_column_with_dot (
k int,
`v1.v2` variant
)
DUPLICATE KEY (`k`)
DISTRIBUTED BY HASH(`k`) BUCKETS 1
PROPERTIES ( "replication_num" = "1");
"""
exception "Disable to create table"
}

// DDL/DML return 1 row and 1 column, the only value is update row count
assertTrue(result1.size() == 1)
assertTrue(result1[0].size() == 1)
Expand All @@ -58,4 +73,19 @@ suite("sql_create_time_range_table") {
def res_show = sql "show create table varchar_0_char_0"
mustContain(res_show[0][1], "varchar(65533)")
mustContain(res_show[0][1], "char(1)")

// variant type column named with '.' character is disabled
sql "DROP TABLE IF EXISTS disable_variant_column_with_dot"
test {
sql """
CREATE TABLE disable_variant_column_with_dot (
k int,
`v1.v2` variant
)
DUPLICATE KEY (`k`)
DISTRIBUTED BY HASH(`k`) BUCKETS 1
PROPERTIES ( "replication_num" = "1");
"""
exception "Disable to create table"
}
}

0 comments on commit f4e6061

Please sign in to comment.