Skip to content

Commit

Permalink
[enhancement](delete) Add a hint msg for forbidden delete when MV or …
Browse files Browse the repository at this point in the history
…rollup exists (#39505)

## Proposed changes

When MV or Rollup exists, delete is forbidden on the base table
currently. Add a hint msg to indicate it.
  • Loading branch information
TangSiyang2001 authored Aug 18, 2024
1 parent 118eb3b commit ff892b3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -446,4 +446,8 @@ public void convertHashDistributionToRandomDistribution() {
distributionInfo = ((HashDistributionInfo) distributionInfo).toRandomDistributionInfo();
}
}

public boolean isRollupIndex(long id) {
return idToVisibleRollupIndex.containsKey(id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,17 @@ public void dispatch() throws Exception {
() -> 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);
}
Expand Down

0 comments on commit ff892b3

Please sign in to comment.