[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:
@ -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();
|
||||
|
||||
Reference in New Issue
Block a user