[Mv] check delete from column exists on mv (#31321)
This commit is contained in:
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user