diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java index 157ad280708485..99bcadee120e9f 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java +++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java @@ -3350,7 +3350,7 @@ public TCreatePartitionResult createPartition(TCreatePartitionRequest request) t return result; } - Table table = db.getTable(tableId).get(); + OlapTable table = (OlapTable) (db.getTable(tableId).get()); if (table == null) { errorStatus.setErrorMsgs( (Lists.newArrayList(String.format("dbId=%d tableId=%d is not exists", dbId, tableId)))); @@ -3432,6 +3432,16 @@ public TCreatePartitionResult createPartition(TCreatePartitionRequest request) t List tablets = Lists.newArrayList(); for (String partitionName : addPartitionClauseMap.keySet()) { Partition partition = table.getPartition(partitionName); + if (partition == null) { + String partInfos = table.getAllPartitions().stream() + .map(partitionArg -> partitionArg.getName() + partitionArg.getId()) + .collect(Collectors.joining(", ")); + + errorStatus.setErrorMsgs(Lists.newArrayList("get partition " + partitionName + " failed")); + result.setStatus(errorStatus); + LOG.warn("send create partition error status: {}, {}", result, partInfos); + return result; + } TOlapTablePartition tPartition = new TOlapTablePartition(); tPartition.setId(partition.getId()); int partColNum = partitionInfo.getPartitionColumns().size();