You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/12/31 05:43:16 UTC
[doris] branch branch-1.2-lts updated: [fix](create-table) wrong judgement about partition column type (#15542)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
new a50b334803 [fix](create-table) wrong judgement about partition column type (#15542)
a50b334803 is described below
commit a50b334803b9258c4b33038a3f6bb2f23f3a3ac8
Author: Mingyu Chen <mo...@163.com>
AuthorDate: Sat Dec 31 13:10:39 2022 +0800
[fix](create-table) wrong judgement about partition column type (#15542)
The following stmt should be success, but return error: `complex type cannt be partition column:ARRAY<VARCHAR(64)>`
```
create table test_array(
task_insert_time BIGINT NOT NULL DEFAULT "0" COMMENT "" ,
task_project ARRAY<VARCHAR(64)> DEFAULT NULL COMMENT "" ,
route_key DATEV2 NOT NULL COMMENT "range分区键"
)
DUPLICATE KEY(`task_insert_time`)
COMMENT ""
PARTITION BY RANGE(route_key)
(PARTITION `p202209` VALUES LESS THAN ("2022-10-01"),
PARTITION `p202210` VALUES LESS THAN ("2022-11-01"),
PARTITION `p202211` VALUES LESS THAN ("2022-12-01"))
DISTRIBUTED BY HASH(`task_insert_time` ) BUCKETS 32
PROPERTIES
(
"replication_num" = "1",
"light_schema_change" = "true"
);
```
This PR fix this
---
.../org/apache/doris/analysis/PartitionDesc.java | 4 +++
.../apache/doris/analysis/RangePartitionDesc.java | 8 ++---
.../org/apache/doris/catalog/CreateTableTest.java | 41 ++++++++++++++++++++++
3 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java
index 8bb42657ae..86a4782cc2 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/PartitionDesc.java
@@ -106,6 +106,10 @@ public class PartitionDesc {
throw new AnalysisException("String Type should not be used in partition column["
+ columnDef.getName() + "].");
}
+ if (columnDef.getType().isComplexType()) {
+ throw new AnalysisException("Complex type column can't be partition column: "
+ + columnDef.getType().toString());
+ }
if (!ConnectContext.get().getSessionVariable().isAllowPartitionColumnNullable()
&& columnDef.isAllowNull()) {
throw new AnalysisException("The partition column must be NOT NULL");
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/RangePartitionDesc.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/RangePartitionDesc.java
index 3d9cae60e5..cc18df6299 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/RangePartitionDesc.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/RangePartitionDesc.java
@@ -84,6 +84,10 @@ public class RangePartitionDesc extends PartitionDesc {
boolean find = false;
for (Column column : schema) {
if (column.getName().equalsIgnoreCase(colName)) {
+ if (column.getType().isComplexType()) {
+ throw new DdlException("Complex type column can't be partition column: "
+ + column.getType().toString());
+ }
try {
RangePartitionInfo.checkPartitionColumn(column);
} catch (AnalysisException e) {
@@ -94,10 +98,6 @@ public class RangePartitionDesc extends PartitionDesc {
find = true;
break;
}
- if (column.getType().isComplexType()) {
- throw new DdlException("Complex type column can't be partition column: "
- + column.getType().toString());
- }
}
if (!find) {
throw new DdlException("Partition column[" + colName + "] does not found");
diff --git a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java
index b12f09bea8..347299c82a 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/catalog/CreateTableTest.java
@@ -644,5 +644,46 @@ public class CreateTableTest {
+ ") distributed by hash(k1) buckets 1\n"
+ "properties(\"replication_num\" = \"1\");");
});
+
+ ExceptionChecker.expectThrowsNoException(() -> {
+ createTable("create table test.test_array( \n"
+ + "task_insert_time BIGINT NOT NULL DEFAULT \"0\" COMMENT \"\" , \n"
+ + "task_project ARRAY<VARCHAR(64)> DEFAULT NULL COMMENT \"\" ,\n"
+ + "route_key DATEV2 NOT NULL COMMENT \"range分区键\"\n"
+ + ") \n"
+ + "DUPLICATE KEY(`task_insert_time`) \n"
+ + " COMMENT \"\"\n"
+ + "PARTITION BY RANGE(route_key) \n"
+ + "(PARTITION `p202209` VALUES LESS THAN (\"2022-10-01\"),\n"
+ + "PARTITION `p202210` VALUES LESS THAN (\"2022-11-01\"),\n"
+ + "PARTITION `p202211` VALUES LESS THAN (\"2022-12-01\")) \n"
+ + "DISTRIBUTED BY HASH(`task_insert_time` ) BUCKETS 32 \n"
+ + "PROPERTIES\n"
+ + "(\n"
+ + " \"replication_num\" = \"1\", \n"
+ + " \"light_schema_change\" = \"true\" \n"
+ + ");");
+ });
+
+ ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "Complex type column can't be partition column",
+ () -> {
+ createTable("create table test.test_array2( \n"
+ + "task_insert_time BIGINT NOT NULL DEFAULT \"0\" COMMENT \"\" , \n"
+ + "task_project ARRAY<VARCHAR(64)> DEFAULT NULL COMMENT \"\" ,\n"
+ + "route_key DATEV2 NOT NULL COMMENT \"range分区键\"\n"
+ + ") \n"
+ + "DUPLICATE KEY(`task_insert_time`) \n"
+ + " COMMENT \"\"\n"
+ + "PARTITION BY RANGE(task_project) \n"
+ + "(PARTITION `p202209` VALUES LESS THAN (\"2022-10-01\"),\n"
+ + "PARTITION `p202210` VALUES LESS THAN (\"2022-11-01\"),\n"
+ + "PARTITION `p202211` VALUES LESS THAN (\"2022-12-01\")) \n"
+ + "DISTRIBUTED BY HASH(`task_insert_time` ) BUCKETS 32 \n"
+ + "PROPERTIES\n"
+ + "(\n"
+ + " \"replication_num\" = \"1\", \n"
+ + " \"light_schema_change\" = \"true\" \n"
+ + ");");
+ });
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org