[Mv] check delete from column exists on mv (#31321)

This commit is contained in:
Pxl
2024-02-26 10:35:08 +08:00
committed by yiguolei
parent 48804a978a
commit 3b7261abe4
3 changed files with 30 additions and 0 deletions

View File

@ -26,6 +26,7 @@ import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.Database;
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.KeysType;
import org.apache.doris.catalog.MaterializedIndexMeta;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.common.Config;
import org.apache.doris.common.ErrorCode;
@ -240,6 +241,17 @@ public class DeleteFromCommand extends Command implements ForwardWithSync {
+ "] is an unique table without merge-on-write.");
}
}
for (String indexName : table.getIndexNameToId().keySet()) {
MaterializedIndexMeta meta = table.getIndexMetaByIndexId(table.getIndexIdByName(indexName));
Set<String> columns = meta.getSchema().stream()
.map(col -> org.apache.doris.analysis.CreateMaterializedViewStmt.mvColumnBreaker(col.getName()))
.collect(Collectors.toSet());
if (!columns.contains(column.getName())) {
throw new AnalysisException("Column[" + column.getName() + "] not exist in index " + indexName
+ ". maybe you need drop the corresponding materialized-view.");
}
}
}
private void checkSubQuery(Plan plan) {