This is an automated email from the ASF dual-hosted git repository.
eldenmoon 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 6cee95540dc branch-2.1: [fix](variant) disable column name with dot
character for variant type #45927 (#45992)
6cee95540dc is described below
commit 6cee95540dced1fac31e2a518b271e4b637dbcad
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Dec 27 19:12:44 2024 +0800
branch-2.1: [fix](variant) disable column name with dot character for
variant type #45927 (#45992)
Cherry-picked from #45927
Co-authored-by: camby <[email protected]>
---
.../org/apache/doris/analysis/CreateTableStmt.java | 5 ++++
.../trees/plans/commands/info/CreateTableInfo.java | 5 ++++
.../suites/ddl_p0/test_create_table.groovy | 30 ++++++++++++++++++++++
3 files changed, 40 insertions(+)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
index 333f4eabc6b..3dccc18730a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/CreateTableStmt.java
@@ -317,6 +317,11 @@ public class CreateTableStmt extends DdlStmt {
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`.");
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
index 638b87c07e0..09c44626e78 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/CreateTableInfo.java
@@ -278,6 +278,11 @@ public class CreateTableInfo {
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`.");
diff --git a/regression-test/suites/ddl_p0/test_create_table.groovy
b/regression-test/suites/ddl_p0/test_create_table.groovy
index 1d3b8409d65..03de74bc289 100644
--- a/regression-test/suites/ddl_p0/test_create_table.groovy
+++ b/regression-test/suites/ddl_p0/test_create_table.groovy
@@ -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)
@@ -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"
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]