[enhancement](delete) Add a hint msg for forbidden delete when MV or rollup exists (#39505) (#39857)

## Proposed changes

When MV or Rollup exists, delete is forbidden on the base table
currently. Add a hint msg to indicate it.
This commit is contained in:
Siyang Tang
2024-08-23 23:42:26 +08:00
committed by GitHub
parent 9d597bde68
commit 00e4f343b0
2 changed files with 9 additions and 1 deletions

View File

@ -474,4 +474,8 @@ public class Partition extends MetaObject implements Writable {
distributionInfo = ((HashDistributionInfo) distributionInfo).toRandomDistributionInfo();
}
}
public boolean isRollupIndex(long id) {
return idToVisibleRollupIndex.containsKey(id);
}
}

View File

@ -313,13 +313,17 @@ public class DeleteJob extends AbstractTxnStateChangeCallback implements DeleteJ
() -> Maps.newTreeMap(String.CASE_INSENSITIVE_ORDER)));
for (Predicate condition : deleteConditions) {
SlotRef slotRef = (SlotRef) condition.getChild(0);
String columnName = new String(slotRef.getColumnName());
String columnName = slotRef.getColumnName();
TColumn column = colNameToColDesc.get(slotRef.getColumnName());
if (column == null) {
columnName = CreateMaterializedViewStmt.mvColumnBuilder(columnName);
column = colNameToColDesc.get(columnName);
}
if (column == null) {
if (partition.isRollupIndex(index.getId())) {
throw new AnalysisException("If MV or rollup index exists, do not support delete."
+ "Drop existing rollup or MV and try again.");
}
throw new AnalysisException(
"condition's column not founded in index, column=" + columnName + " , index=" + index);
}