[fix](truncate) it will directly return and avoid throwing IllegalStateException caused by bufferSize equals zero when table has no partition (#21378)

if table currently has no partition, the truncate SQL will be a empty command, it should directly return and avoid throwing IllegalStateException caused by bufferSize equals zero

Issue Number: close #21316
Co-authored-by: tongyang.han <tongyang.han@jiduauto.com>
This commit is contained in:
htyoung
2023-07-01 08:39:38 +08:00
committed by GitHub
parent 0e17cd4d92
commit 603f4ab20f
2 changed files with 85 additions and 2 deletions

View File

@ -1871,7 +1871,7 @@ public class InternalCatalog implements CatalogIf<Database> {
// create columns
List<Column> baseSchema = stmt.getColumns();
validateColumns(baseSchema, isKeysRequired);
checkAutoIncColummns(baseSchema, keysType);
checkAutoIncColumns(baseSchema, keysType);
// analyze replica allocation
ReplicaAllocation replicaAlloc = PropertyAnalyzer.analyzeReplicaAllocation(stmt.getProperties(), "");
@ -2643,7 +2643,7 @@ public class InternalCatalog implements CatalogIf<Database> {
/*
* check column's auto increment property
*/
private void checkAutoIncColummns(List<Column> columns, KeysType type) throws DdlException {
private void checkAutoIncColumns(List<Column> columns, KeysType type) throws DdlException {
boolean encounterAutoIncColumn = false;
for (Column column : columns) {
if (column.isAutoInc()) {
@ -2710,6 +2710,11 @@ public class InternalCatalog implements CatalogIf<Database> {
partitionsDistributionInfo.put(partition.getId(), partition.getDistributionInfo());
}
}
// if table currently has no partitions, this sql like empty command and do nothing, should return directly
// at the same time, it will avoid throwing IllegalStateException when `bufferSize` equals zero
if (origPartitions.isEmpty()) {
return;
}
copiedTbl = olapTable.selectiveCopy(origPartitions.keySet(), IndexExtState.VISIBLE, false);
} finally {
olapTable.readUnlock();