This is an automated email from the ASF dual-hosted git repository.
xuyang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b1fd124f02 [feature](struct-type/map-type) Add switch for struct and
map type for creating table (#16379)
b1fd124f02 is described below
commit b1fd124f0231c499558e397be3d78a9c9f55fb51
Author: xy720 <[email protected]>
AuthorDate: Fri Feb 3 13:46:52 2023 +0800
[feature](struct-type/map-type) Add switch for struct and map type for
creating table (#16379)
Add switches to forbid uses creating table with struct or map column.
---
.../src/main/java/org/apache/doris/common/Config.java | 12 ++++++++++++
.../org/apache/doris/analysis/CreateTableStmt.java | 18 +++++++++++++-----
.../java/org/apache/doris/catalog/CreateTableTest.java | 18 ++++++++++++++++++
3 files changed, 43 insertions(+), 5 deletions(-)
diff --git a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
index 86215c463a..7e9526d8da 100644
--- a/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
+++ b/fe/fe-common/src/main/java/org/apache/doris/common/Config.java
@@ -1740,6 +1740,18 @@ public class Config extends ConfigBase {
@ConfField(mutable = true, masterOnly = true)
public static boolean enable_array_type = false;
+ /**
+ * Support complex data type MAP.
+ */
+ @ConfField(mutable = true, masterOnly = true)
+ public static boolean enable_map_type = false;
+
+ /**
+ * Support complex data type STRUCT.
+ */
+ @ConfField(mutable = true, masterOnly = true)
+ public static boolean enable_struct_type = false;
+
/**
* The timeout of executing async remote fragment.
* In normal case, the async remote fragment will be executed in a short
time. If system are under high load
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 3bf3b89bcf..75634912cf 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
@@ -427,14 +427,22 @@ public class CreateTableStmt extends DdlStmt {
for (ColumnDef columnDef : columnDefs) {
columnDef.analyze(engineName.equals("olap"));
- if (columnDef.getType().isArrayType() &&
engineName.equals("olap")) {
+ if (columnDef.getType().isComplexType() &&
engineName.equals("olap")) {
+ if (columnDef.getType().isMapType() &&
!Config.enable_map_type) {
+ throw new AnalysisException("Please open enable_map_type
config before use Map.");
+ }
+
+ if (columnDef.getType().isStructType() &&
!Config.enable_struct_type) {
+ throw new AnalysisException("Please open
enable_struct_type config before use Struct.");
+ }
+
if (columnDef.getAggregateType() != null &&
columnDef.getAggregateType() != AggregateType.NONE) {
- throw new AnalysisException("Array column can't support
aggregation "
- + columnDef.getAggregateType());
+ throw new
AnalysisException(columnDef.getType().getPrimitiveType()
+ + " column can't support aggregation " +
columnDef.getAggregateType());
}
if (columnDef.isKey()) {
- throw new AnalysisException("Array can only be used in the
non-key column of"
- + " the duplicate table at present.");
+ throw new
AnalysisException(columnDef.getType().getPrimitiveType()
+ + " can only be used in the non-key column of the
duplicate table at present.");
}
}
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 6b5cfec623..09def4437d 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
@@ -687,4 +687,22 @@ public class CreateTableTest {
+ ");");
});
}
+
+ @Test
+ public void testCreateTableWithMapType() throws Exception {
+ ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "Please
open enable_map_type config before use Map.",
+ () -> {
+ createTable("create table test.test_map(k1 INT, k2
Map<int, VARCHAR(20)>) duplicate key (k1) "
+ + "distributed by hash(k1) buckets 1
properties('replication_num' = '1');");
+ });
+ }
+
+ @Test
+ public void testCreateTableWithStructType() throws Exception {
+ ExceptionChecker.expectThrowsWithMsg(AnalysisException.class, "Please
open enable_struct_type config before use Struct.",
+ () -> {
+ createTable("create table test.test_struct(k1 INT, k2
Struct<f1:int, f2:VARCHAR(20)>) duplicate key (k1) "
+ + "distributed by hash(k1) buckets 1
properties('replication_num' = '1');");
+ });
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]