Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](variant) disable column name with dot character for variant type #45927

Merged
merged 1 commit into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -313,6 +313,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"
}
}
Loading