diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java index 6d98f43c0f..fba382e914 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/info/ColumnDefinition.java @@ -142,12 +142,20 @@ public class ColumnDefinition { throw new AnalysisException("Type exceeds the maximum nesting depth of 9"); } } - if (type.isBitmapType() || type.isHllType() || type.isQuantileStateType()) { + if (type.isHllType() || type.isQuantileStateType()) { if (aggType == null) { - throw new AnalysisException("complex type have to use aggregate function: " + name); + throw new AnalysisException("column: " + name + " must be used in AGG_KEYS."); } isNullable = false; } + if (type.isBitmapType()) { + if (keysType == KeysType.DUP_KEYS) { + throw new AnalysisException("column:" + name + " must be used in AGG_KEYS or UNIQUE_KEYS."); + } + if (aggType != null) { + isNullable = false; + } + } if (keysSet.contains(name)) { isKey = true; if (aggType != null) { 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 f2469c70e6..f398c7b7d1 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 @@ -34,6 +34,7 @@ import org.apache.doris.catalog.Type; import org.apache.doris.cluster.ClusterNamespace; import org.apache.doris.common.Config; import org.apache.doris.common.FeConstants; +import org.apache.doris.common.FeNameFormat; import org.apache.doris.common.util.PropertyAnalyzer; import org.apache.doris.nereids.exceptions.AnalysisException; import org.apache.doris.nereids.types.DataType; @@ -160,6 +161,15 @@ public class CreateTableInfo { properties = Maps.newHashMap(); } + try { + FeNameFormat.checkTableName(tableName); + if (dbName != null) { + FeNameFormat.checkDbName(dbName); + } + } catch (Exception e) { + throw new AnalysisException(e.getMessage(), e); + } + // analyze table name if (dbName == null) { dbName = ClusterNamespace.getFullName(ctx.getClusterName(), ctx.getDatabase()); @@ -314,9 +324,12 @@ public class CreateTableInfo { } partitionNames.add(partitionName); } - Set partitionColumnSets = Sets.newHashSet(partitionColumns); - if (partitionColumnSets.size() != partitionColumns.size()) { - throw new AnalysisException("Duplicate partition keys is not allowed"); + Set partitionColumnSets = Sets.newHashSet(); + List duplicatesKeys = partitionColumns.stream() + .filter(c -> !partitionColumnSets.add(c)) + .collect(Collectors.toList()); + if (!duplicatesKeys.isEmpty()) { + throw new AnalysisException("Duplicated partition column " + duplicatesKeys.get(0)); } partitions.forEach(p -> { p.setPartitionTypes(partitionColumns.stream().map(s -> columnMap.get(s).getType())