This is an automated email from the ASF dual-hosted git repository.
eldenmoon pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 06b7485e5ee branch-3.0: [fix](variant) disable column name with dot
character for variant type #45927 (#45990)
06b7485e5ee is described below
commit 06b7485e5ee0c358f2e0afac6898ac8aeb546830
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Dec 27 18:47:37 2024 +0800
branch-3.0: [fix](variant) disable column name with dot character for
variant type #45927 (#45990)
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 1338632f3fb..1051b7b1748 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
@@ -325,6 +325,11 @@ public class CreateTableStmt extends DdlStmt implements
NotFallbackInParser {
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 0e3c037ecc3..821625576f6 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
@@ -307,6 +307,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]