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

commit 8159b112116b1b5455bd8afa359b39dcc9775c2a
Author: 奕冷 <[email protected]>
AuthorDate: Thu Feb 16 15:05:13 2023 +0800

    [fix](Stmt)pre-block create stmt with column type `ALL` (#16757)
---
 .../org/apache/doris/analysis/CreateTableStmt.java |  9 ++++++-
 .../apache/doris/analysis/CreateTableStmtTest.java | 10 ++++++++
 .../suites/ddl_p0/test_create_blocked.groovy       | 29 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)

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 867cb6aa38..d03f56d4ec 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
@@ -24,6 +24,7 @@ import org.apache.doris.catalog.Env;
 import org.apache.doris.catalog.Index;
 import org.apache.doris.catalog.KeysType;
 import org.apache.doris.catalog.PrimitiveType;
+import org.apache.doris.catalog.Type;
 import org.apache.doris.common.AnalysisException;
 import org.apache.doris.common.Config;
 import org.apache.doris.common.ErrorCode;
@@ -53,6 +54,7 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
 import java.util.stream.Collectors;
@@ -312,7 +314,12 @@ public class CreateTableStmt extends DdlStmt {
         if (properties != null) {
             enableUniqueKeyMergeOnWrite = 
PropertyAnalyzer.analyzeUniqueKeyMergeOnWrite(new HashMap<>(properties));
         }
-
+        //pre-block creation with column type ALL
+        for (ColumnDef columnDef : columnDefs) {
+            if (Objects.equals(columnDef.getType(), Type.ALL)) {
+                throw new AnalysisException("Disable to create table with 
`ALL` type columns.");
+            }
+        }
         // analyze key desc
         if (engineName.equalsIgnoreCase("olap")) {
             // olap table
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java 
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java
index 1f357b2a8d..4b2b352099 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/analysis/CreateTableStmtTest.java
@@ -43,6 +43,7 @@ import org.junit.rules.ExpectedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -241,6 +242,15 @@ public class CreateTableStmtTest {
         stmt.analyze(analyzer);
     }
 
+    @Test(expected = AnalysisException.class)
+    public void testTypeAll() throws UserException {
+        final ArrayList<ColumnDef> colAllList = Lists.newArrayList();
+        colAllList.add(new ColumnDef("colAll", new 
TypeDef(ScalarType.createType(PrimitiveType.ALL))));
+        CreateTableStmt stmt = new CreateTableStmt(false, false, tblNameNoDb, 
colAllList, "olap", new KeysDesc(), null,
+                new RandomDistributionDesc(10), null, null, "");
+        stmt.analyze(analyzer);
+    }
+
 
     @Test
     public void testBmpHllKey() throws Exception {
diff --git a/regression-test/suites/ddl_p0/test_create_blocked.groovy 
b/regression-test/suites/ddl_p0/test_create_blocked.groovy
new file mode 100644
index 0000000000..40c9fb5d22
--- /dev/null
+++ b/regression-test/suites/ddl_p0/test_create_blocked.groovy
@@ -0,0 +1,29 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+suite("test_create_blocked") {
+    try {
+        sql """ 
+                CREATE TABLE test_create_blocked (c1 all) DISTRIBUTED BY 
HASH(c1) PROPERTIES('replication_num'='1'); 
+                """
+        assertTrue(false, "should not be able to execute")
+    } catch (Exception ex) {
+        assertTrue(ex.getMessage().contains("Disable to create table with 
`ALL` type columns"))
+    }finally {
+        sql """ DROP TABLE IF EXISTS test_create_blocked"""
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to