[fix](Stmt)pre-block create stmt with column type ALL (#16757)
This commit is contained in:
@ -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;
|
||||
@ -54,6 +55,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;
|
||||
@ -322,7 +324,12 @@ public class CreateTableStmt extends DdlStmt {
|
||||
enableUniqueKeyMergeOnWrite = PropertyAnalyzer.analyzeUniqueKeyMergeOnWrite(new HashMap<>(properties));
|
||||
enableStoreRowColumn = PropertyAnalyzer.analyzeStoreRowColumn(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
|
||||
|
||||
@ -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 {
|
||||
|
||||
29
regression-test/suites/ddl_p0/test_create_blocked.groovy
Normal file
29
regression-test/suites/ddl_p0/test_create_blocked.groovy
Normal file
@ -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"""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user